1.3.9 • Published 4 years ago

@onepick/nestjs-keycloak v1.3.9

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

nestjs-keycloak

NestJs share library allow services integrate with keycloak. The code cloned from https://github.com/codejamninja/nestjs-keycloak, version 1.3.7

Customized resources at src/auth/*:

  • CurrentUser: Current user parsed from keycloak token
  • AuthenticatedGuard to verify & set userInfo from the token to request

Features

  • nestjs
  • keycloak

Use

In a NestJS API service

npm install @onepick/nestjs-keycloak

Check user has specific roles. At method of *controller.ts, resolver.ts. E.g.

@Authenticated(ROLES.SUPERADMIN, ROLES.SELLER)

Check user can request on a resource (resource & scope must have defined in keycloak). At method of *controller.ts, resolver.ts. E.g.

@Resource('resource_name')
export class MyResolver {

  @Scope('create')
  async create(@User() user: CurrentUser, dto: DTO) {
    ...
  }
}

Build

npm install --save reflect-metadata rxjs
npm run-script build

Publish the library

The library has published as @onepick/nestjs-keycloak by devonepick@gmail.com

npm login

npm publish --access public

Installation

npm install --save onepick/nestjs-keycloak

Dependencies