@onepick/nestjs-keycloak
TypeScript icon, indicating that this package has built-in type declarations

1.3.9 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @onepick/nestjs-keycloak

Weekly Downloads

1

Version

1.3.9

License

MIT

Unpacked Size

76 kB

Total Files

66

Last publish

Collaborators

  • devonepick