1.1.2 • Published 6 months ago
@leadinvr/jwt-guard v1.1.2
leadinvr-jwt-guard
JWT Guard for NestJS framework
Features
- Implement JWT guard in NestJS
Install
npm i @leadinvr/jwt-guardQuick Start
Register Option
// Module Options
export class JWTGuardModuleOptions {
/**
* Redis URL for storing revoked tokens
* This URL is used to connect to a Redis instance where revoked tokens are stored.
* If not provided, the service will use in-memory storage.
* Example: "redis://localhost:6379" or "redis://username:password@localhost:6379"
* @default ""
*/
redisUrl: string = "";
/**
* JWT Secret
*/
secret: string = "";
/**
* Jwt Issuer
*/
issuer?: string;
/**
* Jwt Audience
*/
audience?: string;
}Register
JwtGuardModule.register({
redisUrl: "",
secret: "test-secret",
issuer: "test",
audience: "test",
});
JwtGuardModule.registerAsync({
useFactory: () => ({
redisUrl: "",
secret: "test-secret",
issuer: "test",
audience: "test",
}),
});If autoRegister is false, you need to add provider manually
Trouble Shooting
- JWT Guard Module should register before other guard providers, otherwise the payload may not inject correctly