Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions server/modules/authentication/saml/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ module.exports = {
}
})

// map users LDAP groups to wiki groups with the same name, and remove any groups that don't match LDAP
// map users LDAP groups to wiki groups with the same name,
// and remove any groups that don't match LDAP depending on the sync strategy
// Code stolen from the LDAP implementation with a slight variation on the field we extract the value from
// In SAML v2 groups come in profile.attributes and can be 1 string or an array of strings
if (conf.mapGroups) {
Expand All @@ -70,8 +71,13 @@ module.exports = {
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)

if(['GROUP-SYNC-IDP-ONLY', 'GROUP-SYNC-KEEP-DEFAULTS'].includes(conf.groupSyncStrategy)) {
for (const groupId of _.difference(currentGroups, expectedGroups)) {
if(conf.groupSyncStrategy === 'GROUP-SYNC-IDP-ONLY' || ![1, 2].includes(groupId)) {
await user.$relatedQuery('groups').unrelate().where('groupId', groupId)
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions server/modules/authentication/saml/definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,13 @@ props:
default: 'memberOf'
hint: The field storing the user groups attribute. Can be a variable name or a URI-formatted string.
order: 45
groupSyncStrategy:
type: String
title: Group Synchronization Strategy
hint: Tells the Wiki what to do with local group when mapping with the IdP's groups. GROUP-SYNC-IDP-ONLY= The IdP is the source of truth, only keep its group assignments. GROUP-SYNC-KEEP-DEFAULTS= Same as IDP-ONLY but keep Wiki-js's default groups (Administrators and Guest) if assigned. GROUP-SYNC-KEEP-ALL=Add groups assignment comming from the IdP but keep the local assignments.
default: 'GROUP-SYNC-KEEP-DEFAULTS'
enum:
- GROUP-SYNC-IDP-ONLY
- GROUP-SYNC-KEEP-DEFAULTS
- GROUP-SYNC-KEEP-ALL
order: 46