Skip to content

Commit

Permalink
fix(auth): use jwt secret
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar committed Nov 8, 2024
1 parent 72588b8 commit e75e1b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/modules/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import LocalStrategy from './strategies/local.strategy';
JwtModule.registerAsync({
inject: [ApiConfigService],
useFactory: (configService: ApiConfigService) => ({
secretOrPrivateKey: configService.authConfig.privateKey,
secret: configService.authConfig.secret,
}),
}),
],
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/strategies/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class JwtStrategy extends PassportStrategy(Strategy) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: apiConfigService.authConfig.privateKey,
secretOrKey: apiConfigService.authConfig.secret,
});
}

Expand Down
5 changes: 2 additions & 3 deletions src/shared/services/api-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ export class ApiConfigService {

get authConfig() {
return {
privateKey: this.getString('JWT_PRIVATE_KEY'),
publicKey: this.getString('JWT_PUBLIC_KEY'),
jwtExpirationTime: this.getNumber('JWT_EXPIRATION_TIME'),
secret: this.getString('JWT_SECRET'),
jwtExpirationTime: this.getString('JWT_EXPIRATION_TIME'),
};
}

Expand Down

0 comments on commit e75e1b1

Please sign in to comment.