feat: set groups based on Azure groups (#7736)

Co-authored-by: Ole Christian Tvedt <ole.christian.tvedt@defa.com>
pull/7532/merge
Ole Christian Tvedt 3 weeks ago committed by GitHub
parent 86abfea7f6
commit c093423307
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -48,6 +48,19 @@ module.exports = {
picture: ''
}
})
if (conf.mapGroups) {
const groups = _.get(profile, '_json.groups')
if (groups && _.isArray(groups)) {
const currentGroups = (await user.$relatedQuery('groups').select('groups.id')).map(g => g.id)
const expectedGroups = Object.values(WIKI.auth.groups).filter(g => groups.includes(g.name)).map(g => g.id)
for (const groupId of _.difference(expectedGroups, currentGroups)) {
await user.$relatedQuery('groups').relate(groupId)
}
for (const groupId of _.difference(currentGroups, expectedGroups)) {
await user.$relatedQuery('groups').unrelate().where('groupId', groupId)
}
}
}
cb(null, user)
} catch (err) {
cb(err, null)

@ -27,3 +27,9 @@ props:
title: Cookie Encryption Key String
hint: Random string with 44-character length. Setting this enables workaround for Chrome's SameSite cookies.
order: 3
mapGroups:
type: Boolean
title: Map Groups
hint: Map groups matching names from the groups claim value
default: false
order: 4

Loading…
Cancel
Save