trails-passport-auth
Trails-passport-auth for trails-authentication
Install
$ npm install --save trailpack-passport-auth
Configure
// config/main.jsmoduleexports = packs: // ... other trailpacks
You need to add passportInit
and optionally passportSession
:
// config/web.jsmiddlewares: order: 'addMethods' 'cookieParser' 'session' 'passportInit' 'passportSession' 'bodyParser' 'methodOverride' 'router' 'www' '404' '500'
And to configure sessions:
// config/session.js'use strict' const JwtStrategy = Strategyconst ExtractJwt = ExtractJwt const EXPIRES_IN_SECONDS = 60 * 60 * 24const SECRET = processenvtokenSecret || 'mysupersecuretoken';const ALGORITHM = 'HS256'const ISSUER = 'localhost'const AUDIENCE = 'localhost' moduleexports = 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 { return Promise } 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 local: strategy: Strategy options: usernameField: 'username'
Usage
Now you have your strategy ready for enjoy with passport.
Support and Help
Full support by Jaumard and this all is possible only and only help by him. All Code by Ycpatel813 , I only changed one line of code.