适用于 Nest.js 应用程序的 Keycloak 客户端和管理员提供程序,内置用户管理访问 (UMA) 和 ACL 支持。
适用于 Nest.js 应用程序的 Keycloak 客户端和管理员提供程序,内置用户管理访问 (UMA) 和 ACL 支持。
Install using npm i --save nestjs-keycloak-admin or pnpm add nestjs-keycloak-admin
@keycloak/keycloak-admin-client package, nestjs-keycloak-admin can't support CommonJS at the moment.
The team behind keycloak-admin-client made the decision to have a breaking change and support CommonJS.
Please refer to this Github issue for more information about their decision-making process.Then on your app.module.ts
…By default nestjs-keycloak-admin supports User Managed Access for managing your resources.
…@Get('/hello')
@Roles({roles: ['realm:admin'], mode: RoleMatchingMode.ANY})
sayHello(@User() user: KeycloakUser, @AccessToken() accessToken): string {
return `life is short. -${user.email}/${accessToken}`
}Here is the decorators you can use in your controllers.
| Decorator | Description |
|---|---|
| @User | Retrieves the current Keycloak logged-in user. (must be per method, unless controller is request scoped.) |
| @AccessToken | Retrieves the current access token. (must be per method, unless controller is request scoped.) |
| @DefineResource | Define the keycloak application resource name. |
| @DefineScope | Define the keycloak resource scope (ex: 'create', 'read', 'update', 'delete') |
| @EnforceResource | |
| @FetchResources | |
| @Public | Allow any user to use the route. |
| @Roles | Keycloak realm/application roles. Prefix any realm-level roles with "realm:" (i.e realm:admin) |
暂无开放 Issues,或尚未同步最近议题。