1.3.2 • Published 1 year ago
@xprb/keycloak-operations-manager v1.3.2
keycloak-operations-manager
Installation
$ yarn install @xprb/keycloak-operations-manager
Quick start
import KeycloakOperationsManagerModule into the root AppModule and use the forRootAsync() method to configure it.
KeycloakOperationsManagerModule.forRootAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
baseUrl: configService.get<string>(`keycloakUrl`),
clientId: configService.get<string>('clientId'),
clientSecret: configService.get<string>('clientSecret'),
}),
}),
Afterward, the Keycloak Operations Manager instance will be available to inject across entire project
import { MFA } from '@xprb/keycloak-operations-manager';
@Injectable()
export class DummyService {
constructor(private readonly mfa: MFA) {}
}
Available Injectable Modules
| Module Name
| :-----------------------------
| Auth
| MFA
| Permission
Auth Guard
You can write own auth guard or you can use default one.
import { Module } from '@nestjs/common';
import { ConfigService, ConfigModule as NestConfigModule } from '@nestjs/config';
import { APP_GUARD } from '@nestjs/core';
import { ClsModule } from 'nestjs-cls';
import { REQUEST_ID_HEADER_KEY } from './common';
import { KeycloakOperationsManagerModule, AuthGuard } from '@xprb/keycloak-operations-manager';
import { JwtModule } from '@nestjs/jwt';
@Module({
imports: [
KeycloakOperationsManagerModule.forRootAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
baseUrl: configService.get<string>(`microserviceConfig.urls.auth`),
clientId: configService.get<string>('keycloakConfig.username'),
clientSecret: configService.get<string>('keycloakConfig.password'),
}),
}),
ClsModule.forRoot({
global: true,
middleware: {
mount: true,
generateId: true,
idGenerator: (req: Request) => req.headers[REQUEST_ID_HEADER_KEY],
},
}),
JwtModule
],
controllers: [AppController],
providers: [
{
provide: APP_GUARD,
useClass: AuthGuard,
}
],
})
export class AppModule {}
1.3.2
1 year ago
1.3.1
1 year ago
1.3.0
1 year ago
1.2.12
1 year ago
1.2.11
1 year ago
1.2.10
1 year ago
1.2.9
1 year ago
1.2.8
1 year ago
1.2.7
2 years ago
1.2.6
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago