@pawells/nestjs-auth 1.0.0-dev.4c8c698
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,13 @@
|
|
|
1
|
+
import { ModuleRef } from '@nestjs/core';
|
|
2
|
+
import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
|
|
3
|
+
import { KeycloakAdminService } from '../services/keycloak-admin.service.js';
|
|
4
|
+
import type { KeycloakAdminConfig } from '../config/keycloak.config.js';
|
|
5
|
+
import type { LazyModuleRefService } from '@pawells/nestjs-shared/common';
|
|
6
|
+
export declare class KeycloakHealthIndicator extends HealthIndicator implements LazyModuleRefService {
|
|
7
|
+
readonly Module: ModuleRef;
|
|
8
|
+
get KeycloakAdminService(): KeycloakAdminService;
|
|
9
|
+
get Config(): KeycloakAdminConfig;
|
|
10
|
+
constructor(module: ModuleRef);
|
|
11
|
+
check(key: string): HealthIndicatorResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=keycloak.health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak.health.d.ts","sourceRoot":"","sources":["../../../src/admin/health/keycloak.health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAG7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,qBACa,uBAAwB,SAAQ,eAAgB,YAAW,oBAAoB;IAC3F,SAAgB,MAAM,EAAE,SAAS,CAAC;IAElC,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED,IAAW,MAAM,IAAI,mBAAmB,CAEvC;gBAEW,MAAM,EAAE,SAAS;IAKtB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB;CAqBhD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { ModuleRef } from '@nestjs/core';
|
|
12
|
+
import { HealthIndicator } from '@nestjs/terminus';
|
|
13
|
+
import { KeycloakAdminService } from '../services/keycloak-admin.service.js';
|
|
14
|
+
import { getErrorMessage } from '@pawells/nestjs-shared/common';
|
|
15
|
+
import { KEYCLOAK_ADMIN_CONFIG_TOKEN } from '../keycloak.constants.js';
|
|
16
|
+
let KeycloakHealthIndicator = class KeycloakHealthIndicator extends HealthIndicator {
|
|
17
|
+
Module;
|
|
18
|
+
get KeycloakAdminService() {
|
|
19
|
+
return this.Module.get(KeycloakAdminService);
|
|
20
|
+
}
|
|
21
|
+
get Config() {
|
|
22
|
+
return this.Module.get(KEYCLOAK_ADMIN_CONFIG_TOKEN, { strict: false });
|
|
23
|
+
}
|
|
24
|
+
constructor(module) {
|
|
25
|
+
super();
|
|
26
|
+
this.Module = module;
|
|
27
|
+
}
|
|
28
|
+
check(key) {
|
|
29
|
+
if (!this.Config.enabled) {
|
|
30
|
+
return this.getStatus(key, true, { enabled: false });
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const isAuthenticated = this.KeycloakAdminService.isAuthenticated();
|
|
34
|
+
const client = this.KeycloakAdminService.getClient();
|
|
35
|
+
return this.getStatus(key, isAuthenticated, {
|
|
36
|
+
authenticated: isAuthenticated,
|
|
37
|
+
baseUrl: this.Config.baseUrl,
|
|
38
|
+
realm: this.Config.realmName,
|
|
39
|
+
initialized: client !== null,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return this.getStatus(key, false, {
|
|
44
|
+
error: getErrorMessage(error),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
KeycloakHealthIndicator = __decorate([
|
|
50
|
+
Injectable(),
|
|
51
|
+
__metadata("design:paramtypes", [ModuleRef])
|
|
52
|
+
], KeycloakHealthIndicator);
|
|
53
|
+
export { KeycloakHealthIndicator };
|
|
54
|
+
//# sourceMappingURL=keycloak.health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak.health.js","sourceRoot":"","sources":["../../../src/admin/health/keycloak.health.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAyB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAKhE,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,eAAe;IAC3C,MAAM,CAAY;IAElC,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC9C,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,YAAY,MAAiB;QAC5B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,GAAW;QACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE,CAAC;YACpE,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,CAAC;YAErD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE;gBAC3C,aAAa,EAAE,eAAe;gBAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;gBAC5B,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;gBAC5B,WAAW,EAAE,MAAM,KAAK,IAAI;aAC5B,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE;gBACjC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;aAC7B,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAA;AArCY,uBAAuB;IADnC,UAAU,EAAE;qCAYQ,SAAS;GAXjB,uBAAuB,CAqCnC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { KeycloakAdminModule } from './keycloak-admin.module.js';
|
|
2
|
+
export { KeycloakAdminService } from './services/keycloak-admin.service.js';
|
|
3
|
+
export { KeycloakHealthIndicator } from './health/keycloak.health.js';
|
|
4
|
+
export type { KeycloakAdminConfig } from './config/keycloak.config.js';
|
|
5
|
+
export { KeycloakAdminDefaults, validateKeycloakAdminConfig } from './config/keycloak.defaults.js';
|
|
6
|
+
export { KEYCLOAK_ADMIN_CONFIG_TOKEN } from './keycloak.constants.js';
|
|
7
|
+
export type { KeycloakAdminScope } from './permissions/index.js';
|
|
8
|
+
export { KEYCLOAK_DEFAULT_SCOPES, KEYCLOAK_ALL_SCOPES, KeycloakAdminScopeError } from './permissions/index.js';
|
|
9
|
+
export * from './client/index.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAG/G,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { KeycloakAdminModule } from './keycloak-admin.module.js';
|
|
2
|
+
export { KeycloakAdminService } from './services/keycloak-admin.service.js';
|
|
3
|
+
export { KeycloakHealthIndicator } from './health/keycloak.health.js';
|
|
4
|
+
export { KeycloakAdminDefaults, validateKeycloakAdminConfig } from './config/keycloak.defaults.js';
|
|
5
|
+
export { KEYCLOAK_ADMIN_CONFIG_TOKEN } from './keycloak.constants.js';
|
|
6
|
+
export { KEYCLOAK_DEFAULT_SCOPES, KEYCLOAK_ALL_SCOPES, KeycloakAdminScopeError } from './permissions/index.js';
|
|
7
|
+
// Keycloak Client exports
|
|
8
|
+
export * from './client/index.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAItE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAE/G,0BAA0B;AAC1B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import type { InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
3
|
+
import type { KeycloakAdminConfig } from './config/keycloak.config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Async options for KeycloakAdminModule configuration.
|
|
6
|
+
*
|
|
7
|
+
* Used to defer KeycloakAdminModule setup until runtime dependencies are available.
|
|
8
|
+
* Supports factory functions that return configuration synchronously or asynchronously.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* KeycloakAdminModule.forRootAsync({
|
|
13
|
+
* imports: [ConfigModule],
|
|
14
|
+
* inject: [ConfigService],
|
|
15
|
+
* useFactory: (config: ConfigService) => ({
|
|
16
|
+
* enabled: config.get('KEYCLOAK_ADMIN_ENABLED') === 'true',
|
|
17
|
+
* baseUrl: config.get('KEYCLOAK_BASE_URL'),
|
|
18
|
+
* realmName: config.get('KEYCLOAK_REALM'),
|
|
19
|
+
* credentials: {
|
|
20
|
+
* type: 'clientCredentials',
|
|
21
|
+
* clientId: config.get('KEYCLOAK_ADMIN_CLIENT_ID'),
|
|
22
|
+
* clientSecret: config.get('KEYCLOAK_ADMIN_CLIENT_SECRET'),
|
|
23
|
+
* },
|
|
24
|
+
* }),
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export interface KeycloakAdminModuleAsyncOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Modules to import for dependency resolution.
|
|
31
|
+
* Typically includes {@link ConfigModule} if reading from environment.
|
|
32
|
+
*/
|
|
33
|
+
imports?: ModuleMetadata['imports'];
|
|
34
|
+
/**
|
|
35
|
+
* Factory function that returns KeycloakAdminConfig (sync or async).
|
|
36
|
+
* Receives injected dependencies as arguments.
|
|
37
|
+
*/
|
|
38
|
+
useFactory: (...args: unknown[]) => Promise<KeycloakAdminConfig> | KeycloakAdminConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Array of providers to inject into the factory function.
|
|
41
|
+
* Common values: {@link ConfigService}, custom services, etc.
|
|
42
|
+
*/
|
|
43
|
+
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=keycloak-admin.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.interfaces.d.ts","sourceRoot":"","sources":["../../src/admin/keycloak-admin.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IAEpC;;;OAGG;IACH,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;IAEvF;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,yBAAyB,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.interfaces.js","sourceRoot":"","sources":["../../src/admin/keycloak-admin.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { KeycloakAdminConfig } from './config/keycloak.config.js';
|
|
3
|
+
import type { KeycloakAdminModuleAsyncOptions } from './keycloak-admin.interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Keycloak Admin module for managing users, roles, and groups.
|
|
6
|
+
* Provides Admin API client with configurable authentication methods.
|
|
7
|
+
*/
|
|
8
|
+
export declare class KeycloakAdminModule {
|
|
9
|
+
/**
|
|
10
|
+
* Create Keycloak admin module with static configuration
|
|
11
|
+
* @param config Partial Keycloak admin configuration
|
|
12
|
+
* @returns Dynamic module configuration
|
|
13
|
+
* @throws Error if Keycloak is enabled but credentials are missing
|
|
14
|
+
*/
|
|
15
|
+
static forRoot(config?: Partial<KeycloakAdminConfig>): DynamicModule;
|
|
16
|
+
/**
|
|
17
|
+
* Create Keycloak admin module with asynchronous configuration
|
|
18
|
+
* @param options Async factory configuration
|
|
19
|
+
* @returns Dynamic module configuration
|
|
20
|
+
*/
|
|
21
|
+
static forRootAsync(options: KeycloakAdminModuleAsyncOptions): DynamicModule;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=keycloak-admin.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.module.d.ts","sourceRoot":"","sources":["../../src/admin/keycloak-admin.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAK/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEtF;;;GAGG;AACH,qBAEa,mBAAmB;IAC/B;;;;;OAKG;WACW,OAAO,CAAC,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM,GAAG,aAAa;IAiC/E;;;;OAIG;WACW,YAAY,CAAC,OAAO,EAAE,+BAA+B,GAAG,aAAa;CAmCnF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var KeycloakAdminModule_1;
|
|
8
|
+
import { Module, Global } from '@nestjs/common';
|
|
9
|
+
import { CommonModule } from '@pawells/nestjs-shared/common';
|
|
10
|
+
import { KeycloakAdminService } from './services/keycloak-admin.service.js';
|
|
11
|
+
import { KeycloakHealthIndicator } from './health/keycloak.health.js';
|
|
12
|
+
import { KEYCLOAK_ADMIN_CONFIG_TOKEN } from './keycloak.constants.js';
|
|
13
|
+
import { KeycloakAdminDefaults, validateKeycloakAdminConfig } from './config/keycloak.defaults.js';
|
|
14
|
+
/**
|
|
15
|
+
* Keycloak Admin module for managing users, roles, and groups.
|
|
16
|
+
* Provides Admin API client with configurable authentication methods.
|
|
17
|
+
*/
|
|
18
|
+
let KeycloakAdminModule = KeycloakAdminModule_1 = class KeycloakAdminModule {
|
|
19
|
+
/**
|
|
20
|
+
* Create Keycloak admin module with static configuration
|
|
21
|
+
* @param config Partial Keycloak admin configuration
|
|
22
|
+
* @returns Dynamic module configuration
|
|
23
|
+
* @throws Error if Keycloak is enabled but credentials are missing
|
|
24
|
+
*/
|
|
25
|
+
static forRoot(config = {}) {
|
|
26
|
+
const mergedConfig = { ...KeycloakAdminDefaults, ...config };
|
|
27
|
+
validateKeycloakAdminConfig(mergedConfig);
|
|
28
|
+
// Validate that credentials are provided if Keycloak is enabled
|
|
29
|
+
if (mergedConfig.enabled && mergedConfig.credentials) {
|
|
30
|
+
const creds = mergedConfig.credentials;
|
|
31
|
+
if (creds.type === 'password') {
|
|
32
|
+
if (!creds.username || !creds.password) {
|
|
33
|
+
throw new Error('Keycloak enabled but username/password credentials are empty. Set KEYCLOAK_USERNAME and KEYCLOAK_PASSWORD environment variables.');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (creds.type === 'clientCredentials') {
|
|
37
|
+
if (!creds.clientId || !creds.clientSecret) {
|
|
38
|
+
throw new Error('Keycloak enabled but clientId/clientSecret credentials are empty. Set KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET environment variables.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
module: KeycloakAdminModule_1,
|
|
44
|
+
imports: [CommonModule],
|
|
45
|
+
providers: [
|
|
46
|
+
{
|
|
47
|
+
provide: KEYCLOAK_ADMIN_CONFIG_TOKEN,
|
|
48
|
+
useValue: mergedConfig,
|
|
49
|
+
},
|
|
50
|
+
KeycloakAdminService,
|
|
51
|
+
KeycloakHealthIndicator,
|
|
52
|
+
],
|
|
53
|
+
exports: [KeycloakAdminService, KeycloakHealthIndicator],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create Keycloak admin module with asynchronous configuration
|
|
58
|
+
* @param options Async factory configuration
|
|
59
|
+
* @returns Dynamic module configuration
|
|
60
|
+
*/
|
|
61
|
+
static forRootAsync(options) {
|
|
62
|
+
return {
|
|
63
|
+
module: KeycloakAdminModule_1,
|
|
64
|
+
imports: [CommonModule, ...(options.imports ?? [])],
|
|
65
|
+
providers: [
|
|
66
|
+
{
|
|
67
|
+
provide: KEYCLOAK_ADMIN_CONFIG_TOKEN,
|
|
68
|
+
useFactory: async (...args) => {
|
|
69
|
+
const config = await options.useFactory(...args);
|
|
70
|
+
validateKeycloakAdminConfig(config);
|
|
71
|
+
// Validate that credentials are provided if Keycloak is enabled
|
|
72
|
+
if (config.enabled && config.credentials) {
|
|
73
|
+
const creds = config.credentials;
|
|
74
|
+
if (creds.type === 'password') {
|
|
75
|
+
if (!creds.username || !creds.password) {
|
|
76
|
+
throw new Error('Keycloak enabled but username/password credentials are empty. Set KEYCLOAK_USERNAME and KEYCLOAK_PASSWORD environment variables.');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (creds.type === 'clientCredentials') {
|
|
80
|
+
if (!creds.clientId || !creds.clientSecret) {
|
|
81
|
+
throw new Error('Keycloak enabled but clientId/clientSecret credentials are empty. Set KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET environment variables.');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return config;
|
|
86
|
+
},
|
|
87
|
+
inject: options.inject ?? [],
|
|
88
|
+
},
|
|
89
|
+
KeycloakAdminService,
|
|
90
|
+
KeycloakHealthIndicator,
|
|
91
|
+
],
|
|
92
|
+
exports: [KeycloakAdminService, KeycloakHealthIndicator],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
KeycloakAdminModule = KeycloakAdminModule_1 = __decorate([
|
|
97
|
+
Global(),
|
|
98
|
+
Module({})
|
|
99
|
+
], KeycloakAdminModule);
|
|
100
|
+
export { KeycloakAdminModule };
|
|
101
|
+
//# sourceMappingURL=keycloak-admin.module.js.map
|
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CAAC,4IAA4I,CAAC,CAAC;gCAC/J,CAAC;4BACF,CAAC;wBACF,CAAC;wBAED,OAAO,MAAM,CAAC;oBACf,CAAC;oBACD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;iBAC5B;gBACD,oBAAoB;gBACpB,uBAAuB;aACvB;YACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,uBAAuB,CAAC;SACxD,CAAC;IACH,CAAC;CACD,CAAA;AAhFY,mBAAmB;IAF/B,MAAM,EAAE;IACR,MAAM,CAAC,EAAE,CAAC;GACE,mBAAmB,CAgF/B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection token for the Keycloak Admin configuration object.
|
|
3
|
+
*
|
|
4
|
+
* Use this token when manually injecting the Keycloak admin configuration
|
|
5
|
+
* (typically not required — inject {@link KeycloakAdminService} instead).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* constructor(@Inject(KEYCLOAK_ADMIN_CONFIG_TOKEN) config: KeycloakAdminConfig) {
|
|
10
|
+
* // Access the configuration directly
|
|
11
|
+
* console.log(config.realmName);
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const KEYCLOAK_ADMIN_CONFIG_TOKEN = "KEYCLOAK_ADMIN_CONFIG";
|
|
16
|
+
//# sourceMappingURL=keycloak.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak.constants.d.ts","sourceRoot":"","sources":["../../src/admin/keycloak.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection token for the Keycloak Admin configuration object.
|
|
3
|
+
*
|
|
4
|
+
* Use this token when manually injecting the Keycloak admin configuration
|
|
5
|
+
* (typically not required — inject {@link KeycloakAdminService} instead).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* constructor(@Inject(KEYCLOAK_ADMIN_CONFIG_TOKEN) config: KeycloakAdminConfig) {
|
|
10
|
+
* // Access the configuration directly
|
|
11
|
+
* console.log(config.realmName);
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export const KEYCLOAK_ADMIN_CONFIG_TOKEN = 'KEYCLOAK_ADMIN_CONFIG';
|
|
16
|
+
//# sourceMappingURL=keycloak.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak.constants.js","sourceRoot":"","sources":["../../src/admin/keycloak.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/permissions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/admin/permissions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission scopes for the Keycloak Admin API.
|
|
3
|
+
*
|
|
4
|
+
* Each scope controls access to a category of Keycloak Admin REST API operations.
|
|
5
|
+
* Scopes ending in `:read` permit query/list operations only.
|
|
6
|
+
* Scopes ending in `:write` permit create/update/delete/mutation operations.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link KEYCLOAK_DEFAULT_SCOPES} for the default read-only set
|
|
9
|
+
* @see {@link KEYCLOAK_ALL_SCOPES} for the full set including all write scopes
|
|
10
|
+
*/
|
|
11
|
+
export type KeycloakAdminScope = 'users:read' | 'users:write' | 'roles:read' | 'roles:write' | 'groups:read' | 'groups:write' | 'federated-identity:read' | 'federated-identity:write' | 'events:read' | 'clients:read' | 'clients:write' | 'realms:read' | 'realms:write' | 'identity-providers:read' | 'identity-providers:write' | 'authentication:read' | 'authentication:write';
|
|
12
|
+
/**
|
|
13
|
+
* The default set of scopes granted when no `permissions` array is configured.
|
|
14
|
+
* Contains all read-only scopes. No write scopes are included.
|
|
15
|
+
*/
|
|
16
|
+
export declare const KEYCLOAK_DEFAULT_SCOPES: readonly KeycloakAdminScope[];
|
|
17
|
+
/**
|
|
18
|
+
* All available scopes, including all write scopes.
|
|
19
|
+
* Use this as a convenience constant for adapter microservices that require
|
|
20
|
+
* full access. Ensure the Keycloak service account has all corresponding roles.
|
|
21
|
+
*/
|
|
22
|
+
export declare const KEYCLOAK_ALL_SCOPES: readonly KeycloakAdminScope[];
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when a Keycloak Admin API operation is called but the required
|
|
25
|
+
* permission scope has not been granted in the module configuration.
|
|
26
|
+
*
|
|
27
|
+
* This is a **configuration error**, not a Keycloak HTTP error. It is thrown
|
|
28
|
+
* synchronously before any network request is made.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* try {
|
|
33
|
+
* await keycloakAdminService.users.create(realm, user);
|
|
34
|
+
* } catch (error) {
|
|
35
|
+
* if (error instanceof KeycloakAdminScopeError) {
|
|
36
|
+
* // Service is not configured to create users
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare class KeycloakAdminScopeError extends Error {
|
|
42
|
+
readonly scope: KeycloakAdminScope;
|
|
43
|
+
constructor(scope: KeycloakAdminScope);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=keycloak-admin.permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.permissions.d.ts","sourceRoot":"","sources":["../../../src/admin/permissions/keycloak-admin.permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAC3B,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,aAAa,GACb,aAAa,GACb,cAAc,GACd,yBAAyB,GACzB,0BAA0B,GAC1B,aAAa,GACb,cAAc,GACd,eAAe,GACf,aAAa,GACb,cAAc,GACd,yBAAyB,GACzB,0BAA0B,GAC1B,qBAAqB,GACrB,sBAAsB,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,kBAAkB,EAU/D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EAkB3D,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,SAAgB,KAAK,EAAE,kBAAkB,CAAC;gBAE9B,KAAK,EAAE,kBAAkB;CASrC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default set of scopes granted when no `permissions` array is configured.
|
|
3
|
+
* Contains all read-only scopes. No write scopes are included.
|
|
4
|
+
*/
|
|
5
|
+
export const KEYCLOAK_DEFAULT_SCOPES = Object.freeze([
|
|
6
|
+
'users:read',
|
|
7
|
+
'roles:read',
|
|
8
|
+
'groups:read',
|
|
9
|
+
'federated-identity:read',
|
|
10
|
+
'events:read',
|
|
11
|
+
'clients:read',
|
|
12
|
+
'realms:read',
|
|
13
|
+
'identity-providers:read',
|
|
14
|
+
'authentication:read',
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* All available scopes, including all write scopes.
|
|
18
|
+
* Use this as a convenience constant for adapter microservices that require
|
|
19
|
+
* full access. Ensure the Keycloak service account has all corresponding roles.
|
|
20
|
+
*/
|
|
21
|
+
export const KEYCLOAK_ALL_SCOPES = Object.freeze([
|
|
22
|
+
'users:read',
|
|
23
|
+
'users:write',
|
|
24
|
+
'roles:read',
|
|
25
|
+
'roles:write',
|
|
26
|
+
'groups:read',
|
|
27
|
+
'groups:write',
|
|
28
|
+
'federated-identity:read',
|
|
29
|
+
'federated-identity:write',
|
|
30
|
+
'events:read',
|
|
31
|
+
'clients:read',
|
|
32
|
+
'clients:write',
|
|
33
|
+
'realms:read',
|
|
34
|
+
'realms:write',
|
|
35
|
+
'identity-providers:read',
|
|
36
|
+
'identity-providers:write',
|
|
37
|
+
'authentication:read',
|
|
38
|
+
'authentication:write',
|
|
39
|
+
]);
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when a Keycloak Admin API operation is called but the required
|
|
42
|
+
* permission scope has not been granted in the module configuration.
|
|
43
|
+
*
|
|
44
|
+
* This is a **configuration error**, not a Keycloak HTTP error. It is thrown
|
|
45
|
+
* synchronously before any network request is made.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* try {
|
|
50
|
+
* await keycloakAdminService.users.create(realm, user);
|
|
51
|
+
* } catch (error) {
|
|
52
|
+
* if (error instanceof KeycloakAdminScopeError) {
|
|
53
|
+
* // Service is not configured to create users
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class KeycloakAdminScopeError extends Error {
|
|
59
|
+
scope;
|
|
60
|
+
constructor(scope) {
|
|
61
|
+
super(`Keycloak admin mutation blocked: scope '${scope}' is not granted. ` +
|
|
62
|
+
`Add '${scope}' to the permissions array in KeycloakAdminModule.forRoot() config.`);
|
|
63
|
+
this.name = 'KeycloakAdminScopeError';
|
|
64
|
+
this.scope = scope;
|
|
65
|
+
Error.captureStackTrace(this, this.constructor);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=keycloak-admin.permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.permissions.js","sourceRoot":"","sources":["../../../src/admin/permissions/keycloak-admin.permissions.ts"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAkC,MAAM,CAAC,MAAM,CAAC;IACnF,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,yBAAyB;IACzB,aAAa;IACb,cAAc;IACd,aAAa;IACb,yBAAyB;IACzB,qBAAqB;CACrB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkC,MAAM,CAAC,MAAM,CAAC;IAC/E,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,aAAa;IACb,aAAa;IACb,cAAc;IACd,yBAAyB;IACzB,0BAA0B;IAC1B,aAAa;IACb,cAAc;IACd,eAAe;IACf,aAAa;IACb,cAAc;IACd,yBAAyB;IACzB,0BAA0B;IAC1B,qBAAqB;IACrB,sBAAsB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjC,KAAK,CAAqB;IAE1C,YAAY,KAAyB;QACpC,KAAK,CACJ,2CAA2C,KAAK,oBAAoB;YACpE,QAAQ,KAAK,qEAAqE,CAClF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;CACD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import { KeycloakClient } from '../client/client.js';
|
|
4
|
+
import { AppLogger } from '@pawells/nestjs-shared/common';
|
|
5
|
+
import type { LazyModuleRefService } from '@pawells/nestjs-shared/common';
|
|
6
|
+
import type { KeycloakAdminConfig } from '../config/keycloak.config.js';
|
|
7
|
+
import type { UserService } from '../client/services/user.service.js';
|
|
8
|
+
import type { RealmService } from '../client/services/realm.service.js';
|
|
9
|
+
import type { ClientService } from '../client/services/client.service.js';
|
|
10
|
+
import type { RoleService } from '../client/services/role.service.js';
|
|
11
|
+
import type { GroupService } from '../client/services/group.service.js';
|
|
12
|
+
import type { IdentityProviderService } from '../client/services/identity-provider.service.js';
|
|
13
|
+
import type { AuthenticationService } from '../client/services/authentication.service.js';
|
|
14
|
+
import type { FederatedIdentityService } from '../client/services/federated-identity.service.js';
|
|
15
|
+
import type { EventService } from '../client/services/event.service.js';
|
|
16
|
+
export declare class KeycloakAdminService implements OnModuleInit, LazyModuleRefService {
|
|
17
|
+
private readonly logger;
|
|
18
|
+
private client;
|
|
19
|
+
private grantedScopes;
|
|
20
|
+
readonly Module: ModuleRef;
|
|
21
|
+
get Config(): KeycloakAdminConfig;
|
|
22
|
+
get AppLogger(): AppLogger;
|
|
23
|
+
constructor(module: ModuleRef);
|
|
24
|
+
onModuleInit(): Promise<void>;
|
|
25
|
+
getClient(): KeycloakClient | null;
|
|
26
|
+
isEnabled(): boolean;
|
|
27
|
+
isAuthenticated(): boolean;
|
|
28
|
+
get users(): UserService;
|
|
29
|
+
get realms(): RealmService;
|
|
30
|
+
get clients(): ClientService;
|
|
31
|
+
get roles(): RoleService;
|
|
32
|
+
get groups(): GroupService;
|
|
33
|
+
get identityProviders(): IdentityProviderService;
|
|
34
|
+
get authentication(): AuthenticationService;
|
|
35
|
+
/**
|
|
36
|
+
* Get the federated identity service for managing identity provider links
|
|
37
|
+
*
|
|
38
|
+
* Provides methods to list, link, and unlink external identity providers for users.
|
|
39
|
+
*
|
|
40
|
+
* @returns FederatedIdentityService instance
|
|
41
|
+
* @throws {Error} If Keycloak client is not initialized
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const links = await keycloakAdmin.federatedIdentity.list(userId);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
get federatedIdentity(): FederatedIdentityService;
|
|
49
|
+
/**
|
|
50
|
+
* Get the event service for querying realm events
|
|
51
|
+
*
|
|
52
|
+
* Provides methods to query administrative and access events for audit logging and monitoring.
|
|
53
|
+
*
|
|
54
|
+
* @returns EventService instance
|
|
55
|
+
* @throws {Error} If Keycloak client is not initialized
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const events = await keycloakAdmin.events.getAdminEvents({ max: 100 });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
get events(): EventService;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=keycloak-admin.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-admin.service.d.ts","sourceRoot":"","sources":["../../../src/admin/services/keycloak-admin.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAmB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO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