Unverified Commit 628c72ea authored by Mirco T's avatar Mirco T Committed by GitHub

feat: CAS authentication module (#5452)

parent dffffd3a
const _ = require('lodash')
/* global WIKI */ /* global WIKI */
// ------------------------------------ // ------------------------------------
...@@ -10,15 +11,24 @@ module.exports = { ...@@ -10,15 +11,24 @@ module.exports = {
init (passport, conf) { init (passport, conf) {
passport.use(conf.key, passport.use(conf.key,
new CASStrategy({ new CASStrategy({
ssoBaseURL: conf.ssoBaseURL, version: conf.casVersion,
serverBaseURL: conf.serverBaseURL, ssoBaseURL: conf.casUrl,
serverBaseURL: conf.baseUrl,
serviceURL: conf.callbackURL,
passReqToCallback: true passReqToCallback: true
}, async (req, profile, cb) => { }, async (req, profile, cb) => {
try { try {
const user = await WIKI.models.users.processProfile({ const user = await WIKI.models.users.processProfile({
providerKey: req.params.strategy, 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) cb(null, user)
} catch (err) { } catch (err) {
cb(err, null) cb(err, null)
......
...@@ -6,6 +6,37 @@ logo: https://static.requarks.io/logo/cas.svg ...@@ -6,6 +6,37 @@ logo: https://static.requarks.io/logo/cas.svg
color: green darken-2 color: green darken-2
website: https://apereo.github.io/cas/ website: https://apereo.github.io/cas/
useForm: false useForm: false
isAvailable: true
props: props:
ssoBaseURL: String baseUrl:
serverBaseURL: String type: String
title: Base URL
hint: 'Base-URL of your WikiJS (for example: https://wiki.example.com)'
order: 1
casUrl:
type: String
title: URL to the CAS Server
hint: 'Base-URL of the CAS server, including context path. (for example: https://login.company.com/cas)'
order: 2
casVersion:
type: String
title: CAS Version
hint: 'The version of CAS to use'
order: 3
enum:
- CAS3.0
- CAS1.0
default: 'CAS3.0'
emailAttribute:
type: String
title: Attribute key which contains the users email
default: email
order: 4
displayNameAttribute:
type: String
title: Attribute key which contains the users display name (leave empty if there is none)
order: 5
uniqueIdAttribute:
type: String
title: Attribute key which contains the unique identifier of a user. (if empty, username will be used)
order: 6
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment