1.3.2 • Published 3 months ago

@xprb/keycloak-operations-manager v1.3.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 months ago

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

3 months ago

1.3.1

3 months ago

1.3.0

3 months ago

1.2.12

4 months ago

1.2.11

4 months ago

1.2.10

4 months ago

1.2.9

4 months ago

1.2.8

4 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.2.0

5 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago