1.1.2 • Published 6 months ago

@leadinvr/jwt-guard v1.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 months ago

leadinvr-jwt-guard

JWT Guard for NestJS framework

Features

  • Implement JWT guard in NestJS

Install

npm i @leadinvr/jwt-guard

Quick 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
1.1.2

6 months ago

1.1.0

6 months ago

1.0.8

8 months ago

1.0.6

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago