feat: CAS authentication module (#5452)

Co-authored-by: SeaLife <mtries@united-internet.de>
This commit is contained in:
Mirco T
2022-07-17 01:41:41 +02:00
committed by GitHub
parent dffffd3a2b
commit 628c72ea16
2 changed files with 46 additions and 5 deletions

View File

@@ -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)