feat: CAS authentication module (#5452)
Co-authored-by: SeaLife <mtries@united-internet.de>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const _ = require('lodash')
|
||||
/* global WIKI */
|
||||
|
||||
// ------------------------------------
|
||||
@@ -10,15 +11,24 @@ module.exports = {
|
||||
init (passport, conf) {
|
||||
passport.use(conf.key,
|
||||
new CASStrategy({
|
||||
ssoBaseURL: conf.ssoBaseURL,
|
||||
serverBaseURL: conf.serverBaseURL,
|
||||
version: conf.casVersion,
|
||||
ssoBaseURL: conf.casUrl,
|
||||
serverBaseURL: conf.baseUrl,
|
||||
serviceURL: conf.callbackURL,
|
||||
passReqToCallback: true
|
||||
}, async (req, profile, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
providerKey: req.params.strategy,
|
||||
profile
|
||||
profile: {
|
||||
...profile,
|
||||
id: _.get(profile.attributes, conf.uniqueIdAttribute, profile.user),
|
||||
email: _.get(profile.attributes, conf.emailAttribute),
|
||||
name: _.get(profile.attributes, conf.displayNameAttribute, profile.user),
|
||||
picture: ''
|
||||
}
|
||||
})
|
||||
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
|
Reference in New Issue
Block a user