diff --git a/server/modules/authentication/oidc/authentication.js b/server/modules/authentication/oidc/authentication.js index 4f2dc5cd..8c3ed117 100644 --- a/server/modules/authentication/oidc/authentication.js +++ b/server/modules/authentication/oidc/authentication.js @@ -17,18 +17,21 @@ module.exports = { clientID: conf.clientId, clientSecret: conf.clientSecret, issuer: conf.issuer, + userInfoURL: conf.userInfoURL, 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 - }) + }, async (iss, sub, profile, cb) => { + try { + const user = await WIKI.models.users.processProfile({ + profile: { + ...profile, + email: _.get(profile, '_json.' + conf.emailClaim) + }, + providerKey: 'oidc' + }) + cb(null, user) + } catch(err) { + cb(err, null) + } }) ) } diff --git a/server/modules/authentication/oidc/definition.yml b/server/modules/authentication/oidc/definition.yml index f3f7c191..f10c6e81 100644 --- a/server/modules/authentication/oidc/definition.yml +++ b/server/modules/authentication/oidc/definition.yml @@ -5,13 +5,17 @@ author: requarks.io logo: https://static.requarks.io/logo/oidc.svg color: blue-grey darken-2 website: http://openid.net/connect/ +isAvailable: true useForm: false +scopes: + - openid + - profile + - email props: clientId: String clientSecret: String authorizationURL: String tokenURL: String issuer: String - userInfoUrl: String + userInfoURL: String emailClaim: String - usernameClaim: String