1.1.0 • Published 7 months ago

nest-oidc-validator v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Nest oidc validator

OIDC Token validator for Nestjs.

Getting started

Install Nest oidc validator

npm install nest-oidc-validator

Usage

In authModule

import {NestOidcModule} from 'nest-oidc-validator';
@Module(
  imports: [
    NestOidcModule.forRoot(
      issuer: 'http://.......',  //issuer url
      jwksUri: 'http://.......',  //jwks url
      clientId: 'client',   // cleint id
      jwksRequestsPerMinutes: 5, // optional
      userProp:  'name;family_name...' //token properties for the user.
    )
  ]
)

forRootAsync is available too.
  

In controller

import {NVAuthGuard, NVRoleGuard} from 'nest-oidc-validator';
....

@Roles('admin')
@UseGuards(NVRoleGuard) // role guard.
@UseGuards(NVAuthGuard) // Authentication guard.
@Get("/path")
getSomething() {
  return this.somethingService.getAll();
}
  

If pipes are defined globally and you want some controllers is public you can use @Public decorator:

import {Public} from 'nest-oidc-validator';
....

@Public()
@Get("/path")
getSomethingPublic() {
  return this.somethingServicePublic.getAll();
}
  
1.1.0

7 months ago

1.0.4

7 months ago

1.0.3

8 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.7

11 months ago