src/common/auth/strategies/jwt-auth.strategy.ts
PassportStrategy(Strategy)
Methods |
constructor()
|
| validate | ||||||
validate(payload: any)
|
||||||
|
Parameters :
Returns :
any
|
import { Injectable } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
import { ExtractJwt, Strategy } from "passport-jwt";
import { passportJwtSecret } from "jwks-rsa";
@Injectable()
export class JwtAuthStrategy extends PassportStrategy(Strategy) {
constructor() {
super({
secretOrKeyProvider: passportJwtSecret({
jwksUri: process.env.OAUTH2_JWKS_URL,
}),
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
issuer: process.env.AUTH0_ISSUER_URL,
});
}
validate(payload: any): any {
return payload;
}
}