We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3b09a9 commit d46e455Copy full SHA for d46e455
src/shared/core/infra/auth/jwt.strategy.ts
@@ -0,0 +1,19 @@
1
+import { ExtractJwt, Strategy } from 'passport-jwt';
2
+import { PassportStrategy } from '@nestjs/passport';
3
+import { Injectable } from '@nestjs/common';
4
+import { ENVS } from '../../../../../environments';
5
+
6
+@Injectable()
7
+export class JwtStrategy extends PassportStrategy(Strategy) {
8
+ constructor() {
9
+ super({
10
+ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
11
+ ignoreExpiration: false,
12
+ secretOrKey: ENVS.JWT_TOKEN_SECRET,
13
+ });
14
+ }
15
16
+ async validate(payload: any) {
17
+ return { userId: payload.sub, username: payload.username };
18
19
+}
0 commit comments