CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-keycloak--keycloak-admin-client

A comprehensive TypeScript client library for interacting with Keycloak's Administration API.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

components.mddocs/

Components

Components are pluggable extensions in Keycloak that provide various services such as user storage providers, event listeners, password policies, and other system-level functionality. This interface allows for managing these components programmatically.

Capabilities

Component Management

Core CRUD operations for managing Keycloak components.

/**
 * List components with optional filtering
 * @param query - Optional query parameters for filtering components
 * @returns Array of component representations
 */
find(query?: ComponentQuery): Promise<ComponentRepresentation[]>;

/**
 * Create a new component
 * @param component - Component representation to create
 * @returns Object containing the new component ID
 */
create(component: ComponentRepresentation): Promise<{ id: string }>;

/**
 * Find a component by ID
 * @param params - Parameters containing the component ID
 * @returns Component representation or undefined if not found
 */
findOne(params: { id: string }): Promise<ComponentRepresentation | undefined>;

/**
 * Update a component
 * @param query - Parameters containing the component ID
 * @param component - Updated component representation
 * @returns void
 */
update(query: { id: string }, component: ComponentRepresentation): Promise<void>;

/**
 * Delete a component
 * @param params - Parameters containing the component ID
 * @returns void
 */
del(params: { id: string }): Promise<void>;

/**
 * List sub-component types for a component
 * @param params - Parameters containing component ID and type
 * @returns Array of component type representations
 */
listSubComponents(params: { id: string; type: string }): Promise<ComponentTypeRepresentation[]>;

Usage Examples

import KeycloakAdminClient from "@keycloak/keycloak-admin-client";

const kcAdminClient = new KeycloakAdminClient({
  baseUrl: 'http://localhost:8080',
  realmName: 'myrealm',
});

await kcAdminClient.auth({
  username: 'admin',
  password: 'admin',
  grantType: 'password',
  clientId: 'admin-cli',
});

// List all components
const components = await kcAdminClient.components.find();

// Find user storage providers
const userStorageProviders = await kcAdminClient.components.find({
  type: 'org.keycloak.storage.UserStorageProvider'
});

// Create a custom component (e.g., event listener)
const { id } = await kcAdminClient.components.create({
  name: 'custom-event-listener',
  providerId: 'custom-event-listener-provider',
  providerType: 'org.keycloak.events.EventListenerProvider',
  config: {
    'some-config-key': ['config-value']
  }
});

// Update component configuration
await kcAdminClient.components.update(
  { id },
  {
    name: 'updated-event-listener',
    config: {
      'some-config-key': ['updated-value'],
      'another-key': ['another-value']
    }
  }
);

// List sub-component types
const subTypes = await kcAdminClient.components.listSubComponents({
  id: 'parent-component-id',
  type: 'some-component-type'
});

// Delete a component
await kcAdminClient.components.del({ id });

Types

interface ComponentQuery {
  name?: string;
  parent?: string;
  type?: string;
}

interface ComponentRepresentation {
  id?: string;
  name?: string;
  providerId?: string;
  providerType?: string;
  parentId?: string;
  subType?: string;
  config?: Record<string, string[]>;
}

interface ComponentTypeRepresentation {
  id?: string;
  helpText?: string;
  properties?: ConfigPropertyRepresentation[];
}

interface ConfigPropertyRepresentation {
  name?: string;
  label?: string;
  helpText?: string;
  type?: string;
  defaultValue?: any;
  options?: string[];
  secret?: boolean;
}

docs

attack-detection.md

authentication-management.md

cache-management.md

client-configuration.md

client-management.md

client-policies.md

client-scopes.md

components.md

group-management.md

identity-providers.md

index.md

organization-management.md

realm-management.md

role-management.md

server-info.md

user-management.md

user-storage-provider.md

utility-functions.md

whoami.md

tile.json