-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add idp-based prefix to gid #474
base: stable-3.2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -660,17 +660,43 @@ public function updateAttributes($uid, | |
} | ||
|
||
if ($newGroups !== null) { | ||
$prefix = ''; | ||
$mapping = $this->config->getSystemValue('user_saml.unique_groups_per_idp', ''); | ||
if ($mapping === '') { | ||
$mapping = $this->config->getAppValue('user_saml', 'unique_groups_per_idp', ''); | ||
} | ||
|
||
if ($mapping !== '' && | ||
array_key_exists($mapping, $attributes) && | ||
is_array($attributes[$mapping]) && | ||
sizeof($attributes[$mapping]) === 1) { | ||
Comment on lines
+669
to
+672
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd fancy to have the operators on the left handside for better readability. On the right they are rugged and thus harder to spot. I am not sure whether we have written it down though in the coding style though. |
||
$realUid = $attributes[$mapping][0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking of user id but that's not what it should be, or did I misunderstand it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to avoid a spoof of the domain from one of the idp |
||
list(, $idp) = explode('@', $realUid); | ||
$prefix = substr(md5($idp), 0, 7); | ||
$newGroups = array_map( | ||
function($g) use ($prefix) { | ||
return $prefix . '-' . $g; | ||
}, $newGroups | ||
); | ||
} | ||
|
||
$groupManager = $this->groupManager; | ||
$oldGroups = $groupManager->getUserGroupIds($user); | ||
|
||
$groupsToAdd = array_unique(array_diff($newGroups, $oldGroups)); | ||
$groupsToRemove = array_diff($oldGroups, $newGroups); | ||
|
||
foreach ($groupsToAdd as $group) { | ||
if (!($groupManager->groupExists($group))) { | ||
$groupManager->createGroup($group); | ||
foreach ($groupsToAdd as $gid) { | ||
if (!($groupManager->groupExists($gid))) { | ||
$group = $groupManager->createGroup($gid); | ||
if ($prefix !== '') { | ||
$group->setDisplayName(substr($gid, strlen($prefix) + 1)); | ||
} | ||
} else { | ||
$group = $groupManager->get($gid); | ||
} | ||
$groupManager->get($group)->addUser($user); | ||
|
||
$group->addUser($user); | ||
} | ||
|
||
foreach ($groupsToRemove as $group) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are both settings new? then let's leave out the system one. do not need to make it more bloated then necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requested by customer to have the config in config/config.php instead of using the
occ config:app:set