1.1.0 • Published 7 months ago
nest-oidc-validator v1.1.0
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();
}