1.0.18 • Published 4 years ago
@darren_gannon/auth0 v1.0.18
darren_gannon/auth0
Install
npm i @darren_gannon/auth0Usage
Import AuthzModule in AppModule
@Module({
imports: [
Auth0Module.register({
issuer: string
audience: string
extractUserPermissions: (context: ExecutionContext) => string[]
mapRequiredPermissions?: (permissions: string[], context: ExecutionContext) => string[]
}),
],
})
export class AppModule {}Attach the AuthzGuard
This can be done either directly on the global scope or on a request handler
Globally
@Module({
providers: [
{
provide: APP_GUARD,
useClass: AuthzGuard,
},
],
})
export class AppModule {}Per request handler
@UseGuards(AuthzGuard)
@Controller()
export class AppController {
@Get()
getDate(): string {
return new Date().toISOString();
}
}Validate Permissions
Define the required permissions
This can be done at a class and method scope
Class scope
@Permissions("permission_str")
export class AppController { }Method scope
export class AppController {
@Permissions("permission_str")
@Get()
getHello() {
return "Hello World!"
}
}1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago