2.2.1 • Published 4 years ago
@nest-firebase/security v2.2.1
@nest-firebase/security
Description
This module provides protection to actions/queries through decorators.
Installation
$ npm install --save @nest-firebase/securityMethods
| Name | Description | .env |
|---|---|---|
| @isUser() | Acccepts an array of string roles and validate if token is valid and user has one of the requested roles to proceed. If no role is informed, it only check if token belongs to a valid user | USER_AUTH_URL |
| @isClient() | Use google-auth-library to verify the integrity of the ID token | OAUTH_AUDIENCE |
| @CurrentUser() | Get a payload with token owner data. |
Usage
Just annotate yout REST actions and Graphql queries/mutations methods with decorator.
The client should send a Bearer authorization header e.g., 'Authorization: Bearer JWT_TOKEN'.
You can also use the @CurrentUser param annotation to get access to the current user.
- Add
USER_AUTH_URLorOAUTH_AUDIENCEto .env
USER_AUTH_URL='https://knowledge-staging.skore.io/workspace/v1/users/current'
OAUTH_AUDIENCE='https://test.skore.io'- Import the decorator and have fun
import { IsUser, CurrentUser } from '@nest-firebase/security'
@Controller('users')
export class UserController {
@IsUser(['admin', 'expert'])
@Get()
async hello(@CurrentUser() user: any): string {
return user.companyId
}
}2.2.1
4 years ago
2.0.3
4 years ago
2.1.1
4 years ago
2.0.5
4 years ago
2.0.4
4 years ago
2.1.0
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.9.1
4 years ago
1.9.0
4 years ago
1.8.0
4 years ago
1.7.2
5 years ago
1.7.0
5 years ago
1.7.4
5 years ago
1.5.10
6 years ago
1.5.9
6 years ago
1.5.5
6 years ago
1.5.8
6 years ago
1.5.7
6 years ago
1.5.6
6 years ago
1.5.4
6 years ago
1.5.3
6 years ago
1.5.2
6 years ago
1.5.1
6 years ago
1.5.0
6 years ago
1.4.4
6 years ago
1.4.3
6 years ago