-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession.js
47 lines (43 loc) · 1.13 KB
/
session.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
const JwtStrategy = require('passport-jwt').Strategy
const ExtractJwt = require('passport-jwt').ExtractJwt
const EXPIRES_IN_SECONDS = 60 * 60 * 24
const SECRET = process.env.tokenSecret || 'mysupersecuretoken';
const ALGORITHM = 'HS256'
const ISSUER = 'localhost'
const AUDIENCE = 'localhost'
module.exports = {
secret: SECRET,//secret use by express for his sessions
redirect: {
login: '/',//Login successful
logout: '/'//Logout successful
},
//Called when user is logged, before returning the json response
onUserLogged: (app, user) => {
return Promise.resolve(user)
},
strategies: {
jwt: {
strategy: JwtStrategy,
tokenOptions: {
expiresInSeconds: EXPIRES_IN_SECONDS,
secret: SECRET,
algorithm: ALGORITHM,
issuer: ISSUER,
audience: AUDIENCE
},
options: {
secretOrKey: SECRET,
issuer: ISSUER,
audience: AUDIENCE,
jwtFromRequest: ExtractJwt.fromAuthHeader()
}
},
local: {
strategy: require('passport-local').Strategy,
options: {
usernameField: 'username'
}
}
}
}