Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Add JWT audience
Browse files Browse the repository at this point in the history
  • Loading branch information
auscompgeek committed Oct 12, 2019
1 parent a11683c commit 8044376
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"pass": "password"
},
"jwt": {
"audience": "https://api.syncs.org.au",
"secret": "supersecret",
"duration": "6h"
},
Expand Down
7 changes: 5 additions & 2 deletions src/core/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const config = require("../../../config.json");
PassportModule,
JwtModule.register({
secret: config.jwt.secret,
signOptions: { expiresIn: config.jwt.duration },
})
signOptions: {
audience: config.jwt.audience,
expiresIn: config.jwt.duration,
},
}),
],
exports: [AuthService],
providers: [AuthService, LocalStrategy, JwtStrategy],
Expand Down
1 change: 1 addition & 0 deletions src/core/auth/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: config.jwt.secret,
audience: config.jwt.audience,
});
}

Expand Down

0 comments on commit 8044376

Please sign in to comment.