feat: authentication improvements

This commit is contained in:
NGPixel
2018-08-04 17:27:55 -04:00
committed by Nicolas Giard
parent 2817c72ec3
commit bcd6ceb271
39 changed files with 1727 additions and 1828 deletions

View File

@@ -0,0 +1,35 @@
const _ = require('lodash')
/* global WIKI */
// ------------------------------------
// OpenID Connect Account
// ------------------------------------
const OpenIDConnectStrategy = require('passport-openidconnect').Strategy
module.exports = {
init (passport, conf) {
passport.use('oidc',
new OpenIDConnectStrategy({
authorizationURL: conf.authorizationURL,
tokenURL: conf.tokenURL,
clientID: conf.clientId,
clientSecret: conf.clientSecret,
issuer: conf.issuer,
callbackURL: conf.callbackURL
}, (iss, sub, profile, jwtClaims, accessToken, refreshToken, params, cb) => {
WIKI.models.users.processProfile({
id: jwtClaims.sub,
provider: 'oidc',
email: _.get(jwtClaims, conf.emailClaim),
name: _.get(jwtClaims, conf.usernameClaim)
}).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
})
)
}
}

View File

@@ -0,0 +1,16 @@
key: oidc
title: Generic OpenID Connect
description: OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 protocol.
author: requarks.io
logo: https://static.requarks.io/logo/oidc.svg
website: http://openid.net/connect/
useForm: false
props:
clientId: String
clientSecret: String
authorizationURL: String
tokenURL: String
issuer: String
userInfoUrl: String
emailClaim: String
usernameClaim: String