-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
const {Passport} = require('passport'); | ||
|
||
const {Strategy} = require('passport-jwt'); | ||
const config = require('./auth_config_private')(); | ||
const PermissionError = require('core/errors/factoryError')('PermissionError'); | ||
|
||
module.exports = function () { | ||
const passport = new Passport(); | ||
|
||
const strategy = new Strategy(config.jwtSecret, function (payload, done) { | ||
|
||
const {noauth} = payload; | ||
|
||
const countern = process.env.MAESTRO_NOAUTH || "defaultSecretNoAuthToken" | ||
|
||
if (noauth === countern) { | ||
return done(null, payload); | ||
} | ||
return done(new PermissionError("Invalid token"), false); | ||
|
||
}); | ||
|
||
passport.use(strategy); | ||
|
||
return { | ||
initialize: () => { | ||
return passport.initialize(); | ||
}, | ||
authenticate: () => { | ||
return passport.authenticate("jwt", config.jwtSession); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const {ExtractJwt} = require('passport-jwt'); | ||
|
||
module.exports = () => { | ||
const secret = process.env.MAESTRO_SECRETJWT_PRIVATE; | ||
|
||
return { | ||
jwtSecret: { | ||
secretOrKey: secret || 'defaultSecretKeyPrivate', | ||
jwtFromRequest: ExtractJwt.fromAuthHeaderWithScheme('jwt') | ||
}, | ||
jwtSession: { | ||
session: false | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const privateAuth = require('identity/config/auth_conector_private'); | ||
|
||
module.exports = function () { | ||
return privateAuth().authenticate(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters