@pawells/nestjs-auth 1.0.0-dev.3052c75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +602 -0
- package/build/LICENSE +21 -0
- package/build/README.md +602 -0
- package/build/admin/client/client.d.ts +82 -0
- package/build/admin/client/client.d.ts.map +1 -0
- package/build/admin/client/client.js +157 -0
- package/build/admin/client/client.js.map +1 -0
- package/build/admin/client/errors/base-error.d.ts +58 -0
- package/build/admin/client/errors/base-error.d.ts.map +1 -0
- package/build/admin/client/errors/base-error.js +100 -0
- package/build/admin/client/errors/base-error.js.map +1 -0
- package/build/admin/client/errors/index.d.ts +2 -0
- package/build/admin/client/errors/index.d.ts.map +1 -0
- package/build/admin/client/errors/index.js +2 -0
- package/build/admin/client/errors/index.js.map +1 -0
- package/build/admin/client/index.d.ts +6 -0
- package/build/admin/client/index.d.ts.map +1 -0
- package/build/admin/client/index.js +11 -0
- package/build/admin/client/index.js.map +1 -0
- package/build/admin/client/services/authentication.service.d.ts +54 -0
- package/build/admin/client/services/authentication.service.d.ts.map +1 -0
- package/build/admin/client/services/authentication.service.js +99 -0
- package/build/admin/client/services/authentication.service.js.map +1 -0
- package/build/admin/client/services/base-service.d.ts +39 -0
- package/build/admin/client/services/base-service.d.ts.map +1 -0
- package/build/admin/client/services/base-service.js +107 -0
- package/build/admin/client/services/base-service.js.map +1 -0
- package/build/admin/client/services/client.service.d.ts +86 -0
- package/build/admin/client/services/client.service.d.ts.map +1 -0
- package/build/admin/client/services/client.service.js +193 -0
- package/build/admin/client/services/client.service.js.map +1 -0
- package/build/admin/client/services/event.service.d.ts +84 -0
- package/build/admin/client/services/event.service.d.ts.map +1 -0
- package/build/admin/client/services/event.service.js +155 -0
- package/build/admin/client/services/event.service.js.map +1 -0
- package/build/admin/client/services/federated-identity.service.d.ts +89 -0
- package/build/admin/client/services/federated-identity.service.d.ts.map +1 -0
- package/build/admin/client/services/federated-identity.service.js +120 -0
- package/build/admin/client/services/federated-identity.service.js.map +1 -0
- package/build/admin/client/services/group.service.d.ts +52 -0
- package/build/admin/client/services/group.service.d.ts.map +1 -0
- package/build/admin/client/services/group.service.js +105 -0
- package/build/admin/client/services/group.service.js.map +1 -0
- package/build/admin/client/services/identity-provider.service.d.ts +47 -0
- package/build/admin/client/services/identity-provider.service.d.ts.map +1 -0
- package/build/admin/client/services/identity-provider.service.js +86 -0
- package/build/admin/client/services/identity-provider.service.js.map +1 -0
- package/build/admin/client/services/index.d.ts +11 -0
- package/build/admin/client/services/index.d.ts.map +1 -0
- package/build/admin/client/services/index.js +11 -0
- package/build/admin/client/services/index.js.map +1 -0
- package/build/admin/client/services/realm.service.d.ts +41 -0
- package/build/admin/client/services/realm.service.d.ts.map +1 -0
- package/build/admin/client/services/realm.service.js +80 -0
- package/build/admin/client/services/realm.service.js.map +1 -0
- package/build/admin/client/services/role.service.d.ts +45 -0
- package/build/admin/client/services/role.service.d.ts.map +1 -0
- package/build/admin/client/services/role.service.js +92 -0
- package/build/admin/client/services/role.service.js.map +1 -0
- package/build/admin/client/services/user.service.d.ts +84 -0
- package/build/admin/client/services/user.service.d.ts.map +1 -0
- package/build/admin/client/services/user.service.js +216 -0
- package/build/admin/client/services/user.service.js.map +1 -0
- package/build/admin/client/types/config.types.d.ts +59 -0
- package/build/admin/client/types/config.types.d.ts.map +1 -0
- package/build/admin/client/types/config.types.js +13 -0
- package/build/admin/client/types/config.types.js.map +1 -0
- package/build/admin/client/types/event.types.d.ts +176 -0
- package/build/admin/client/types/event.types.d.ts.map +1 -0
- package/build/admin/client/types/event.types.js +2 -0
- package/build/admin/client/types/event.types.js.map +1 -0
- package/build/admin/client/types/index.d.ts +4 -0
- package/build/admin/client/types/index.d.ts.map +1 -0
- package/build/admin/client/types/index.js +4 -0
- package/build/admin/client/types/index.js.map +1 -0
- package/build/admin/client/types/keycloak.types.d.ts +169 -0
- package/build/admin/client/types/keycloak.types.d.ts.map +1 -0
- package/build/admin/client/types/keycloak.types.js +2 -0
- package/build/admin/client/types/keycloak.types.js.map +1 -0
- package/build/admin/client/utils/index.d.ts +2 -0
- package/build/admin/client/utils/index.d.ts.map +1 -0
- package/build/admin/client/utils/index.js +2 -0
- package/build/admin/client/utils/index.js.map +1 -0
- package/build/admin/client/utils/retry.d.ts +40 -0
- package/build/admin/client/utils/retry.d.ts.map +1 -0
- package/build/admin/client/utils/retry.js +72 -0
- package/build/admin/client/utils/retry.js.map +1 -0
- package/build/admin/config/keycloak.config.d.ts +33 -0
- package/build/admin/config/keycloak.config.d.ts.map +1 -0
- package/build/admin/config/keycloak.config.js +2 -0
- package/build/admin/config/keycloak.config.js.map +1 -0
- package/build/admin/config/keycloak.defaults.d.ts +11 -0
- package/build/admin/config/keycloak.defaults.d.ts.map +1 -0
- package/build/admin/config/keycloak.defaults.js +60 -0
- package/build/admin/config/keycloak.defaults.js.map +1 -0
- package/build/admin/health/keycloak.health.d.ts +13 -0
- package/build/admin/health/keycloak.health.d.ts.map +1 -0
- package/build/admin/health/keycloak.health.js +54 -0
- package/build/admin/health/keycloak.health.js.map +1 -0
- package/build/admin/index.d.ts +10 -0
- package/build/admin/index.d.ts.map +1 -0
- package/build/admin/index.js +9 -0
- package/build/admin/index.js.map +1 -0
- package/build/admin/keycloak-admin.interfaces.d.ts +45 -0
- package/build/admin/keycloak-admin.interfaces.d.ts.map +1 -0
- package/build/admin/keycloak-admin.interfaces.js +2 -0
- package/build/admin/keycloak-admin.interfaces.js.map +1 -0
- package/build/admin/keycloak-admin.module.d.ts +23 -0
- package/build/admin/keycloak-admin.module.d.ts.map +1 -0
- package/build/admin/keycloak-admin.module.js +101 -0
- package/build/admin/keycloak-admin.module.js.map +1 -0
- package/build/admin/keycloak.constants.d.ts +16 -0
- package/build/admin/keycloak.constants.d.ts.map +1 -0
- package/build/admin/keycloak.constants.js +16 -0
- package/build/admin/keycloak.constants.js.map +1 -0
- package/build/admin/permissions/index.d.ts +2 -0
- package/build/admin/permissions/index.d.ts.map +1 -0
- package/build/admin/permissions/index.js +2 -0
- package/build/admin/permissions/index.js.map +1 -0
- package/build/admin/permissions/keycloak-admin.permissions.d.ts +45 -0
- package/build/admin/permissions/keycloak-admin.permissions.d.ts.map +1 -0
- package/build/admin/permissions/keycloak-admin.permissions.js +68 -0
- package/build/admin/permissions/keycloak-admin.permissions.js.map +1 -0
- package/build/admin/services/keycloak-admin.service.d.ts +64 -0
- package/build/admin/services/keycloak-admin.service.d.ts.map +1 -0
- package/build/admin/services/keycloak-admin.service.js +152 -0
- package/build/admin/services/keycloak-admin.service.js.map +1 -0
- package/build/decorators/auth-decorators.d.ts +217 -0
- package/build/decorators/auth-decorators.d.ts.map +1 -0
- package/build/decorators/auth-decorators.js +251 -0
- package/build/decorators/auth-decorators.js.map +1 -0
- package/build/decorators/context-utils.d.ts +101 -0
- package/build/decorators/context-utils.d.ts.map +1 -0
- package/build/decorators/context-utils.js +178 -0
- package/build/decorators/context-utils.js.map +1 -0
- package/build/decorators/graphql-auth-decorators.d.ts +144 -0
- package/build/decorators/graphql-auth-decorators.d.ts.map +1 -0
- package/build/decorators/graphql-auth-decorators.js +152 -0
- package/build/decorators/graphql-auth-decorators.js.map +1 -0
- package/build/decorators/index.d.ts +5 -0
- package/build/decorators/index.d.ts.map +1 -0
- package/build/decorators/index.js +4 -0
- package/build/decorators/index.js.map +1 -0
- package/build/guards/index.d.ts +4 -0
- package/build/guards/index.d.ts.map +1 -0
- package/build/guards/index.js +4 -0
- package/build/guards/index.js.map +1 -0
- package/build/guards/jwt-auth.guard.d.ts +52 -0
- package/build/guards/jwt-auth.guard.d.ts.map +1 -0
- package/build/guards/jwt-auth.guard.js +97 -0
- package/build/guards/jwt-auth.guard.js.map +1 -0
- package/build/guards/permission.guard.d.ts +37 -0
- package/build/guards/permission.guard.d.ts.map +1 -0
- package/build/guards/permission.guard.js +73 -0
- package/build/guards/permission.guard.js.map +1 -0
- package/build/guards/role.guard.d.ts +33 -0
- package/build/guards/role.guard.d.ts.map +1 -0
- package/build/guards/role.guard.js +69 -0
- package/build/guards/role.guard.js.map +1 -0
- package/build/index.d.ts +92 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +98 -0
- package/build/index.js.map +1 -0
- package/build/keycloak/index.d.ts +7 -0
- package/build/keycloak/index.d.ts.map +1 -0
- package/build/keycloak/index.js +5 -0
- package/build/keycloak/index.js.map +1 -0
- package/build/keycloak/keycloak.constants.d.ts +2 -0
- package/build/keycloak/keycloak.constants.d.ts.map +1 -0
- package/build/keycloak/keycloak.constants.js +2 -0
- package/build/keycloak/keycloak.constants.js.map +1 -0
- package/build/keycloak/keycloak.interfaces.d.ts +12 -0
- package/build/keycloak/keycloak.interfaces.d.ts.map +1 -0
- package/build/keycloak/keycloak.interfaces.js +2 -0
- package/build/keycloak/keycloak.interfaces.js.map +1 -0
- package/build/keycloak/keycloak.module.d.ts +56 -0
- package/build/keycloak/keycloak.module.d.ts.map +1 -0
- package/build/keycloak/keycloak.module.js +104 -0
- package/build/keycloak/keycloak.module.js.map +1 -0
- package/build/keycloak/keycloak.types.d.ts +60 -0
- package/build/keycloak/keycloak.types.d.ts.map +1 -0
- package/build/keycloak/keycloak.types.js +2 -0
- package/build/keycloak/keycloak.types.js.map +1 -0
- package/build/keycloak/services/jwks-cache.service.d.ts +64 -0
- package/build/keycloak/services/jwks-cache.service.d.ts.map +1 -0
- package/build/keycloak/services/jwks-cache.service.js +176 -0
- package/build/keycloak/services/jwks-cache.service.js.map +1 -0
- package/build/keycloak/services/keycloak-token-validation.service.d.ts +88 -0
- package/build/keycloak/services/keycloak-token-validation.service.d.ts.map +1 -0
- package/build/keycloak/services/keycloak-token-validation.service.js +243 -0
- package/build/keycloak/services/keycloak-token-validation.service.js.map +1 -0
- package/build/package.json +72 -0
- package/package.json +93 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BaseService } from './base-service.js';
|
|
2
|
+
/**
|
|
3
|
+
* Federated identity link representation
|
|
4
|
+
*/
|
|
5
|
+
export interface FederatedIdentityLink {
|
|
6
|
+
identityProvider: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
userName: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Federated Identity Service
|
|
12
|
+
*
|
|
13
|
+
* Wraps the Keycloak Admin API for managing federated identity links.
|
|
14
|
+
* Federated identities allow users to link external identity providers (e.g., GitHub, Google, OIDC)
|
|
15
|
+
* to their Keycloak account.
|
|
16
|
+
*
|
|
17
|
+
* Uses internal deduplication to prevent duplicate links (see workaround for Keycloak issue #34608).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const links = await keycloakAdmin.federatedIdentity.list(userId);
|
|
22
|
+
* await keycloakAdmin.federatedIdentity.link(userId, 'github', {
|
|
23
|
+
* userId: 'github-user-123',
|
|
24
|
+
* userName: 'john_doe'
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class FederatedIdentityService extends BaseService {
|
|
29
|
+
/**
|
|
30
|
+
* List all federated identity links for a user
|
|
31
|
+
*
|
|
32
|
+
* Retrieves all external identity provider links associated with a Keycloak user.
|
|
33
|
+
* Uses the Keycloak Admin API endpoint: `GET /admin/realms/{realm}/users/{id}/federated-identity`
|
|
34
|
+
*
|
|
35
|
+
* @param userId - The Keycloak user ID
|
|
36
|
+
* @returns Array of federated identity links (may be empty)
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const links = await this.federatedIdentity.list('user-123');
|
|
41
|
+
* // [
|
|
42
|
+
* // { identityProvider: 'github', userId: 'octocat', userName: 'octocat' },
|
|
43
|
+
* // { identityProvider: 'google', userId: 'google-id', userName: 'john@example.com' }
|
|
44
|
+
* // ]
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
list(userId: string): Promise<FederatedIdentityLink[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Link a federated identity to a user
|
|
50
|
+
*
|
|
51
|
+
* Associates an external identity provider account with a Keycloak user.
|
|
52
|
+
* Includes internal deduplication check to prevent duplicate links (workaround for Keycloak issue #34608).
|
|
53
|
+
*
|
|
54
|
+
* Throws `ConflictError` if a link with the same provider and user ID already exists.
|
|
55
|
+
*
|
|
56
|
+
* Note: This method requires both `federated-identity:write` and `federated-identity:read` scopes.
|
|
57
|
+
* The read scope is needed for the internal check performed by {@link list}.
|
|
58
|
+
*
|
|
59
|
+
* @param userId - The Keycloak user ID to link to
|
|
60
|
+
* @param provider - The identity provider name (e.g., 'github', 'google', 'keycloak-oidc')
|
|
61
|
+
* @param link - The external identity details (userId and userName from the external provider)
|
|
62
|
+
* @throws {ConflictError} If a link with this provider and userId already exists
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* await this.federatedIdentity.link('user-123', 'github', {
|
|
67
|
+
* userId: 'octocat',
|
|
68
|
+
* userName: 'octocat'
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
link(userId: string, provider: string, link: Omit<FederatedIdentityLink, 'identityProvider'>): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Unlink a federated identity from a user
|
|
75
|
+
*
|
|
76
|
+
* Removes an external identity provider link from a Keycloak user.
|
|
77
|
+
* After unlinking, the user can no longer authenticate via that provider.
|
|
78
|
+
*
|
|
79
|
+
* @param userId - The Keycloak user ID
|
|
80
|
+
* @param provider - The identity provider name to remove
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* await this.federatedIdentity.unlink('user-123', 'github');
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
unlink(userId: string, provider: string): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=federated-identity.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated-identity.service.d.ts","sourceRoot":"","sources":["../../../../src/admin/client/services/federated-identity.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACxD;;;;;;;;;;;;;;;;;OAiBG;IACU,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAWnE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,IAAI,CAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,GACnD,OAAO,CAAC,IAAI,CAAC;IA+BhB;;;;;;;;;;;;;OAaG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ConflictError } from '../errors/index.js';
|
|
2
|
+
import { BaseService } from './base-service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Federated Identity Service
|
|
5
|
+
*
|
|
6
|
+
* Wraps the Keycloak Admin API for managing federated identity links.
|
|
7
|
+
* Federated identities allow users to link external identity providers (e.g., GitHub, Google, OIDC)
|
|
8
|
+
* to their Keycloak account.
|
|
9
|
+
*
|
|
10
|
+
* Uses internal deduplication to prevent duplicate links (see workaround for Keycloak issue #34608).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const links = await keycloakAdmin.federatedIdentity.list(userId);
|
|
15
|
+
* await keycloakAdmin.federatedIdentity.link(userId, 'github', {
|
|
16
|
+
* userId: 'github-user-123',
|
|
17
|
+
* userName: 'john_doe'
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class FederatedIdentityService extends BaseService {
|
|
22
|
+
/**
|
|
23
|
+
* List all federated identity links for a user
|
|
24
|
+
*
|
|
25
|
+
* Retrieves all external identity provider links associated with a Keycloak user.
|
|
26
|
+
* Uses the Keycloak Admin API endpoint: `GET /admin/realms/{realm}/users/{id}/federated-identity`
|
|
27
|
+
*
|
|
28
|
+
* @param userId - The Keycloak user ID
|
|
29
|
+
* @returns Array of federated identity links (may be empty)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const links = await this.federatedIdentity.list('user-123');
|
|
34
|
+
* // [
|
|
35
|
+
* // { identityProvider: 'github', userId: 'octocat', userName: 'octocat' },
|
|
36
|
+
* // { identityProvider: 'google', userId: 'google-id', userName: 'john@example.com' }
|
|
37
|
+
* // ]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
async list(userId) {
|
|
41
|
+
this.requireScope('federated-identity:read');
|
|
42
|
+
try {
|
|
43
|
+
return (await this.withRetry(() => this.adminClient.users.listFederatedIdentities({ id: userId })));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return this.handleError(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Link a federated identity to a user
|
|
51
|
+
*
|
|
52
|
+
* Associates an external identity provider account with a Keycloak user.
|
|
53
|
+
* Includes internal deduplication check to prevent duplicate links (workaround for Keycloak issue #34608).
|
|
54
|
+
*
|
|
55
|
+
* Throws `ConflictError` if a link with the same provider and user ID already exists.
|
|
56
|
+
*
|
|
57
|
+
* Note: This method requires both `federated-identity:write` and `federated-identity:read` scopes.
|
|
58
|
+
* The read scope is needed for the internal check performed by {@link list}.
|
|
59
|
+
*
|
|
60
|
+
* @param userId - The Keycloak user ID to link to
|
|
61
|
+
* @param provider - The identity provider name (e.g., 'github', 'google', 'keycloak-oidc')
|
|
62
|
+
* @param link - The external identity details (userId and userName from the external provider)
|
|
63
|
+
* @throws {ConflictError} If a link with this provider and userId already exists
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* await this.federatedIdentity.link('user-123', 'github', {
|
|
68
|
+
* userId: 'octocat',
|
|
69
|
+
* userName: 'octocat'
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
async link(userId, provider, link) {
|
|
74
|
+
this.requireScope('federated-identity:write');
|
|
75
|
+
try {
|
|
76
|
+
// Check for existing link with same provider and userId to prevent Keycloak #34608
|
|
77
|
+
const existingLinks = await this.list(userId);
|
|
78
|
+
const conflictingLink = existingLinks.find((l) => l.identityProvider === provider && l.userId === link.userId);
|
|
79
|
+
if (conflictingLink) {
|
|
80
|
+
throw new ConflictError(`Federated identity link already exists: provider=${provider}, userId=${link.userId}`);
|
|
81
|
+
}
|
|
82
|
+
await this.withRetry(() => this.adminClient.users.addToFederatedIdentity({
|
|
83
|
+
id: userId,
|
|
84
|
+
federatedIdentityId: provider,
|
|
85
|
+
federatedIdentity: {
|
|
86
|
+
identityProvider: provider,
|
|
87
|
+
userId: link.userId,
|
|
88
|
+
userName: link.userName,
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.handleError(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Unlink a federated identity from a user
|
|
98
|
+
*
|
|
99
|
+
* Removes an external identity provider link from a Keycloak user.
|
|
100
|
+
* After unlinking, the user can no longer authenticate via that provider.
|
|
101
|
+
*
|
|
102
|
+
* @param userId - The Keycloak user ID
|
|
103
|
+
* @param provider - The identity provider name to remove
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* await this.federatedIdentity.unlink('user-123', 'github');
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
async unlink(userId, provider) {
|
|
111
|
+
this.requireScope('federated-identity:write');
|
|
112
|
+
try {
|
|
113
|
+
await this.withRetry(() => this.adminClient.users.delFromFederatedIdentity({ id: userId, federatedIdentityId: provider }));
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
this.handleError(error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=federated-identity.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated-identity.service.js","sourceRoot":"","sources":["../../../../src/admin/client/services/federated-identity.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,wBAAyB,SAAQ,WAAW;IACxD;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,IAAI,CAAC,MAAc;QAC/B,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;QAC7C,IAAI,CAAC;YACJ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAC9D,CAA4B,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACI,KAAK,CAAC,IAAI,CAChB,MAAc,EACd,QAAgB,EAChB,IAAqD;QAErD,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;QAC9C,IAAI,CAAC;YACJ,mFAAmF;YACnF,MA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CACD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { GroupRepresentation } from '../types/index.js';
|
|
2
|
+
import { BaseService } from './base-service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Service for managing Keycloak groups.
|
|
5
|
+
*
|
|
6
|
+
* Provides methods for creating, listing, and managing user groups. Groups can be nested hierarchically,
|
|
7
|
+
* have roles assigned to them, and be used to organize users. Requires `groups:read` and `groups:write`
|
|
8
|
+
* scopes depending on the operation.
|
|
9
|
+
*
|
|
10
|
+
* Part of {@link KeycloakAdminService.groups | KeycloakAdminService#groups}.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const groups = await keycloak.groups.list('my-realm');
|
|
15
|
+
* const group = await keycloak.groups.get('my-realm', 'group-id');
|
|
16
|
+
* await keycloak.groups.create('my-realm', { name: 'developers', path: '/developers' });
|
|
17
|
+
* await keycloak.groups.addMember('my-realm', 'group-id', 'user-id');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class GroupService extends BaseService {
|
|
21
|
+
/**
|
|
22
|
+
* List all groups in a realm
|
|
23
|
+
*/
|
|
24
|
+
list(realm: string): Promise<GroupRepresentation[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a group by ID
|
|
27
|
+
*/
|
|
28
|
+
get(realm: string, groupId: string): Promise<GroupRepresentation>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new group
|
|
31
|
+
*/
|
|
32
|
+
create(realm: string, group: GroupRepresentation): Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Update a group
|
|
37
|
+
*/
|
|
38
|
+
update(realm: string, groupId: string, group: GroupRepresentation): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a group
|
|
41
|
+
*/
|
|
42
|
+
delete(realm: string, groupId: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Add a user to a group
|
|
45
|
+
*/
|
|
46
|
+
addMember(realm: string, groupId: string, userId: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Remove a user from a group
|
|
49
|
+
*/
|
|
50
|
+
removeMember(realm: string, groupId: string, userId: string): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=group.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.service.d.ts","sourceRoot":"","sources":["../../../../src/admin/client/services/group.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC5C;;OAEG;IACU,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAShE;;OAEG;IACU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAW9E;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAWvF;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAW9F;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlE;;OAEG;IACU,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrF;;OAEG;IACU,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUxF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BaseService } from './base-service.js';
|
|
2
|
+
/**
|
|
3
|
+
* Service for managing Keycloak groups.
|
|
4
|
+
*
|
|
5
|
+
* Provides methods for creating, listing, and managing user groups. Groups can be nested hierarchically,
|
|
6
|
+
* have roles assigned to them, and be used to organize users. Requires `groups:read` and `groups:write`
|
|
7
|
+
* scopes depending on the operation.
|
|
8
|
+
*
|
|
9
|
+
* Part of {@link KeycloakAdminService.groups | KeycloakAdminService#groups}.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const groups = await keycloak.groups.list('my-realm');
|
|
14
|
+
* const group = await keycloak.groups.get('my-realm', 'group-id');
|
|
15
|
+
* await keycloak.groups.create('my-realm', { name: 'developers', path: '/developers' });
|
|
16
|
+
* await keycloak.groups.addMember('my-realm', 'group-id', 'user-id');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class GroupService extends BaseService {
|
|
20
|
+
/**
|
|
21
|
+
* List all groups in a realm
|
|
22
|
+
*/
|
|
23
|
+
async list(realm) {
|
|
24
|
+
this.requireScope('groups:read');
|
|
25
|
+
try {
|
|
26
|
+
return (await this.withRetry(() => this.adminClient.groups.find({ realm })));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return this.handleError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get a group by ID
|
|
34
|
+
*/
|
|
35
|
+
async get(realm, groupId) {
|
|
36
|
+
this.requireScope('groups:read');
|
|
37
|
+
try {
|
|
38
|
+
return (await this.withRetry(() => this.adminClient.groups.findOne({ realm, id: groupId })));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return this.handleError(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a new group
|
|
46
|
+
*/
|
|
47
|
+
async create(realm, group) {
|
|
48
|
+
this.requireScope('groups:write');
|
|
49
|
+
try {
|
|
50
|
+
return await this.withRetry(() => this.adminClient.groups.create({ ...group, realm }));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return this.handleError(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Update a group
|
|
58
|
+
*/
|
|
59
|
+
async update(realm, groupId, group) {
|
|
60
|
+
this.requireScope('groups:write');
|
|
61
|
+
try {
|
|
62
|
+
await this.withRetry(() => this.adminClient.groups.update({ realm, id: groupId }, group));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.handleError(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Delete a group
|
|
70
|
+
*/
|
|
71
|
+
async delete(realm, groupId) {
|
|
72
|
+
this.requireScope('groups:write');
|
|
73
|
+
try {
|
|
74
|
+
await this.withRetry(() => this.adminClient.groups.del({ realm, id: groupId }));
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.handleError(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add a user to a group
|
|
82
|
+
*/
|
|
83
|
+
async addMember(realm, groupId, userId) {
|
|
84
|
+
this.requireScope('groups:write');
|
|
85
|
+
try {
|
|
86
|
+
await this.withRetry(() => this.adminClient.users.addToGroup({ realm, id: userId, groupId }));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.handleError(error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Remove a user from a group
|
|
94
|
+
*/
|
|
95
|
+
async removeMember(realm, groupId, userId) {
|
|
96
|
+
this.requireScope('groups:write');
|
|
97
|
+
try {
|
|
98
|
+
await this.withRetry(() => this.adminClient.users.delFromGroup({ realm, id: userId, groupId }));
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
this.handleError(error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=group.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.service.js","sourceRoot":"","sources":["../../../../src/admin/client/services/group.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC5C;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,KAAa;QAC9B,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC;YACJ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAQ,CAAC;QACrF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,OAAe;QAC9C,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC;YACJ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACjC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CACvD,CAAQ,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;OAEG;IACI,KAAK,C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,CAAC,SAAS,CAAC,KAAa,EAAE,OAAe,EAAE,MAAc;QACpE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAClC,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACzB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CACjE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,OAAe,EAAE,MAAc;QACvE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAClC,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACzB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CACnE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IdentityProviderRepresentation } from '../types/index.js';
|
|
2
|
+
import { BaseService } from './base-service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Service for managing Keycloak identity providers.
|
|
5
|
+
*
|
|
6
|
+
* Provides methods for configuring external identity providers (e.g., social login, SAML, OIDC).
|
|
7
|
+
* Identity providers enable federated authentication — users can log in via external identity systems
|
|
8
|
+
* that are then linked to Keycloak accounts. Requires `identity-providers:read` and
|
|
9
|
+
* `identity-providers:write` scopes depending on the operation.
|
|
10
|
+
*
|
|
11
|
+
* Part of {@link KeycloakAdminService.identityProviders | KeycloakAdminService#identityProviders}.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const idps = await keycloak.identityProviders.list('my-realm');
|
|
16
|
+
* const googleIdp = await keycloak.identityProviders.get('my-realm', 'google');
|
|
17
|
+
* await keycloak.identityProviders.create('my-realm', {
|
|
18
|
+
* alias: 'github',
|
|
19
|
+
* providerId: 'github',
|
|
20
|
+
* enabled: true,
|
|
21
|
+
* config: { clientId: '...', clientSecret: '...' },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class IdentityProviderService extends BaseService {
|
|
26
|
+
/**
|
|
27
|
+
* List all identity providers in a realm
|
|
28
|
+
*/
|
|
29
|
+
list(realm: string): Promise<IdentityProviderRepresentation[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Get an identity provider by alias
|
|
32
|
+
*/
|
|
33
|
+
get(realm: string, alias: string): Promise<IdentityProviderRepresentation>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new identity provider
|
|
36
|
+
*/
|
|
37
|
+
create(realm: string, idp: IdentityProviderRepresentation): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Update an identity provider
|
|
40
|
+
*/
|
|
41
|
+
update(realm: string, alias: string, idp: IdentityProviderRepresentation): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete an identity provider
|
|
44
|
+
*/
|
|
45
|
+
delete(realm: string, alias: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=identity-provider.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-provider.service.d.ts","sourceRoot":"","sources":["../../../../src/admin/client/services/identity-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,uBAAwB,SAAQ,WAAW;IACvD;;OAEG;IACU,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;IAW3E;;OAEG;IACU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAWvF;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtF;;OAEG;IACU,MAAM,CAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,8BAA8B,GACjC,OAAO,CAAC,IAAI,CAAC;IAWhB;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUhE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BaseService } from './base-service.js';
|
|
2
|
+
/**
|
|
3
|
+
* Service for managing Keycloak identity providers.
|
|
4
|
+
*
|
|
5
|
+
* Provides methods for configuring external identity providers (e.g., social login, SAML, OIDC).
|
|
6
|
+
* Identity providers enable federated authentication — users can log in via external identity systems
|
|
7
|
+
* that are then linked to Keycloak accounts. Requires `identity-providers:read` and
|
|
8
|
+
* `identity-providers:write` scopes depending on the operation.
|
|
9
|
+
*
|
|
10
|
+
* Part of {@link KeycloakAdminService.identityProviders | KeycloakAdminService#identityProviders}.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const idps = await keycloak.identityProviders.list('my-realm');
|
|
15
|
+
* const googleIdp = await keycloak.identityProviders.get('my-realm', 'google');
|
|
16
|
+
* await keycloak.identityProviders.create('my-realm', {
|
|
17
|
+
* alias: 'github',
|
|
18
|
+
* providerId: 'github',
|
|
19
|
+
* enabled: true,
|
|
20
|
+
* config: { clientId: '...', clientSecret: '...' },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class IdentityProviderService extends BaseService {
|
|
25
|
+
/**
|
|
26
|
+
* List all identity providers in a realm
|
|
27
|
+
*/
|
|
28
|
+
async list(realm) {
|
|
29
|
+
this.requireScope('identity-providers:read');
|
|
30
|
+
try {
|
|
31
|
+
return (await this.withRetry(() => this.adminClient.identityProviders.find({ realm })));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return this.handleError(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get an identity provider by alias
|
|
39
|
+
*/
|
|
40
|
+
async get(realm, alias) {
|
|
41
|
+
this.requireScope('identity-providers:read');
|
|
42
|
+
try {
|
|
43
|
+
return (await this.withRetry(() => this.adminClient.identityProviders.findOne({ realm, alias })));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return this.handleError(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new identity provider
|
|
51
|
+
*/
|
|
52
|
+
async create(realm, idp) {
|
|
53
|
+
this.requireScope('identity-providers:write');
|
|
54
|
+
try {
|
|
55
|
+
await this.withRetry(() => this.adminClient.identityProviders.create({ ...idp, realm }));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.handleError(error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Update an identity provider
|
|
63
|
+
*/
|
|
64
|
+
async update(realm, alias, idp) {
|
|
65
|
+
this.requireScope('identity-providers:write');
|
|
66
|
+
try {
|
|
67
|
+
await this.withRetry(() => this.adminClient.identityProviders.update({ realm, alias }, idp));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.handleError(error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Delete an identity provider
|
|
75
|
+
*/
|
|
76
|
+
async delete(realm, alias) {
|
|
77
|
+
this.requireScope('identity-providers:write');
|
|
78
|
+
try {
|
|
79
|
+
await this.withRetry(() => this.adminClient.identityProviders.del({ realm, alias }));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
this.handleError(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=identity-provider.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-provider.service.js","sourceRoot":"","sources":["../../../../src/admin/client/services/identity-provider.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACvD;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,KAAa;QAC9B,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;QAC7C,IAAI,CAAC;YACJ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACjC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAClD,CAAQ,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,KAAa;QAC5C,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;QAC7C,IAAI,CAAC;YACJ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACjC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAC5D,CAAQ,CAAC;QACX,CAAC;QAAC,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EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './base-service.js';
|
|
2
|
+
export * from './realm.service.js';
|
|
3
|
+
export * from './user.service.js';
|
|
4
|
+
export * from './client.service.js';
|
|
5
|
+
export * from './role.service.js';
|
|
6
|
+
export * from './group.service.js';
|
|
7
|
+
export * from './identity-provider.service.js';
|
|
8
|
+
export * from './authentication.service.js';
|
|
9
|
+
export * from './federated-identity.service.js';
|
|
10
|
+
export * from './event.service.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/admin/client/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './base-service.js';
|
|
2
|
+
export * from './realm.service.js';
|
|
3
|
+
export * from './user.service.js';
|
|
4
|
+
export * from './client.service.js';
|
|
5
|
+
export * from './role.service.js';
|
|
6
|
+
export * from './group.service.js';
|
|
7
|
+
export * from './identity-provider.service.js';
|
|
8
|
+
export * from './authentication.service.js';
|
|
9
|
+
export * from './federated-identity.service.js';
|
|
10
|
+
export * from './event.service.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/admin/client/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RealmRepresentation } from '../types/index.js';
|
|
2
|
+
import { BaseService } from './base-service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Service for managing Keycloak realms.
|
|
5
|
+
*
|
|
6
|
+
* Provides methods for querying and updating realm-level configuration, including realm properties,
|
|
7
|
+
* security policy, login settings, and event configuration. Requires `realms:read` and `realms:write`
|
|
8
|
+
* scopes depending on the operation.
|
|
9
|
+
*
|
|
10
|
+
* Part of {@link KeycloakAdminService.realms | KeycloakAdminService#realms}.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const realm = await keycloak.realms.get('my-realm');
|
|
15
|
+
* const realms = await keycloak.realms.list();
|
|
16
|
+
* await keycloak.realms.update('my-realm', { accessTokenLifespan: 3600 });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class RealmService extends BaseService {
|
|
20
|
+
/**
|
|
21
|
+
* List all realms
|
|
22
|
+
*/
|
|
23
|
+
list(): Promise<RealmRepresentation[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Get a realm by name
|
|
26
|
+
*/
|
|
27
|
+
get(realm: string): Promise<RealmRepresentation>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new realm
|
|
30
|
+
*/
|
|
31
|
+
create(realm: RealmRepresentation): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Update a realm
|
|
34
|
+
*/
|
|
35
|
+
update(realmName: string, realm: RealmRepresentation): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Delete a realm
|
|
38
|
+
*/
|
|
39
|
+
delete(realm: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=realm.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realm.service.d.ts","sourceRoot":"","sources":["../../../../src/admin/client/services/realm.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC5C;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IASnD;;OAEG;IACU,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAW7D;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D;;OAEG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWjF;;OAEG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQjD"}
|