feat: map OIDC/OAuth2 avatar claims to user pictureUrl (#7908)

pull/7914/head
mod242 8 months ago committed by GitHub
parent 3dcf20ab6f
commit 6ae53bf1bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -22,13 +22,15 @@ module.exports = {
state: conf.enableCSRFProtection state: conf.enableCSRFProtection
}, async (req, accessToken, refreshToken, profile, cb) => { }, async (req, accessToken, refreshToken, profile, cb) => {
try { try {
const picture = _.get(profile, conf.pictureClaim, '')
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, ...profile,
id: _.get(profile, conf.userIdClaim), id: _.get(profile, conf.userIdClaim),
displayName: _.get(profile, conf.displayNameClaim, '???'), displayName: _.get(profile, conf.displayNameClaim, '???'),
email: _.get(profile, conf.emailClaim) email: _.get(profile, conf.emailClaim),
picture: picture
} }
}) })
if (conf.mapGroups) { if (conf.mapGroups) {

@ -54,38 +54,45 @@ props:
default: email default: email
maxWidth: 500 maxWidth: 500
order: 8 order: 8
pictureClaim:
type: String
title: Picture Claim
hint: Field containing the user avatar URL
default: picture
maxWidth: 500
order: 9
mapGroups: mapGroups:
type: Boolean type: Boolean
title: Map Groups title: Map Groups
hint: Map groups matching names from the groups claim value hint: Map groups matching names from the groups claim value
default: false default: false
order: 9 order: 10
groupsClaim: groupsClaim:
type: String type: String
title: Groups Claim title: Groups Claim
hint: Field containing the group names hint: Field containing the group names
default: groups default: groups
maxWidth: 500 maxWidth: 500
order: 10 order: 11
logoutURL: logoutURL:
type: String type: String
title: Logout URL title: Logout URL
hint: (optional) Logout URL on the OAuth2 provider where the user will be redirected to complete the logout process. hint: (optional) Logout URL on the OAuth2 provider where the user will be redirected to complete the logout process.
order: 11 order: 12
scope: scope:
type: String type: String
title: Scope title: Scope
hint: (optional) Application Client permission scopes. hint: (optional) Application Client permission scopes.
order: 12 order: 13
useQueryStringForAccessToken: useQueryStringForAccessToken:
type: Boolean type: Boolean
default: false default: false
title: Pass access token via GET query string to User Info Endpoint title: Pass access token via GET query string to User Info Endpoint
hint: (optional) Pass the access token in an `access_token` parameter attached to the GET query string of the User Info Endpoint URL. Otherwise the access token will be passed in the Authorization header. hint: (optional) Pass the access token in an `access_token` parameter attached to the GET query string of the User Info Endpoint URL. Otherwise the access token will be passed in the Authorization header.
order: 13 order: 14
enableCSRFProtection: enableCSRFProtection:
type: Boolean type: Boolean
default: true default: true
title: Enable CSRF protection title: Enable CSRF protection
hint: Pass a nonce state parameter during authentication to protect against CSRF attacks. hint: Pass a nonce state parameter during authentication to protect against CSRF attacks.
order: 14 order: 15

@ -24,6 +24,7 @@ module.exports = {
acrValues: conf.acrValues acrValues: conf.acrValues
}, async (req, iss, uiProfile, idProfile, context, idToken, accessToken, refreshToken, params, cb) => { }, async (req, iss, uiProfile, idProfile, context, idToken, accessToken, refreshToken, params, cb) => {
const profile = Object.assign({}, idProfile, uiProfile) const profile = Object.assign({}, idProfile, uiProfile)
const picture = _.get(profile, '_json.' + conf.pictureClaim, '')
try { try {
const user = await WIKI.models.users.processProfile({ const user = await WIKI.models.users.processProfile({
@ -31,7 +32,8 @@ module.exports = {
profile: { profile: {
...profile, ...profile,
email: _.get(profile, '_json.' + conf.emailClaim), email: _.get(profile, '_json.' + conf.emailClaim),
displayName: _.get(profile, '_json.' + conf.displayNameClaim, '') displayName: _.get(profile, '_json.' + conf.displayNameClaim, ''),
picture: picture
} }
}) })
if (conf.mapGroups) { if (conf.mapGroups) {

@ -62,26 +62,33 @@ props:
default: displayName default: displayName
maxWidth: 500 maxWidth: 500
order: 9 order: 9
pictureClaim:
type: String
title: Picture Claim
hint: Field containing the user avatar URL
default: picture
maxWidth: 500
order: 10
mapGroups: mapGroups:
type: Boolean type: Boolean
title: Map Groups title: Map Groups
hint: Map groups matching names from the groups claim value hint: Map groups matching names from the groups claim value
default: false default: false
order: 10 order: 11
groupsClaim: groupsClaim:
type: String type: String
title: Groups Claim title: Groups Claim
hint: Field containing the group names hint: Field containing the group names
default: groups default: groups
maxWidth: 500 maxWidth: 500
order: 11 order: 12
logoutURL: logoutURL:
type: String type: String
title: Logout URL title: Logout URL
hint: (optional) Logout URL on the OAuth2 provider where the user will be redirected to complete the logout process. hint: (optional) Logout URL on the OAuth2 provider where the user will be redirected to complete the logout process.
order: 12 order: 13
acrValues: acrValues:
type: String type: String
title: ACR Values title: ACR Values
hint: (optional) Authentication Context Class Reference hint: (optional) Authentication Context Class Reference
order: 13 order: 14

Loading…
Cancel
Save