Skip to content
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

Pull recent release changes back into develop #372

Merged
merged 13 commits into from
Sep 18, 2024
Merged
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
13 changes: 10 additions & 3 deletions application/common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,17 +1052,24 @@ public static function updateUsersExternalGroups(
return $errors;
}

$desiredExternalGroupsByLowercaseUserEmail = [];
foreach ($desiredExternalGroupsByUserEmail as $email => $groups) {
$desiredExternalGroupsByLowercaseUserEmail[mb_strtolower($email)] = $groups;
}
unset($desiredExternalGroupsByUserEmail);

$emailAddressesOfCurrentMatches = self::listUsersWithExternalGroupWith($appPrefix);

// Indicate that users not in the "desired" list should not have any
// such external groups.
foreach ($emailAddressesOfCurrentMatches as $email) {
if (! array_key_exists($email, $desiredExternalGroupsByUserEmail)) {
$desiredExternalGroupsByUserEmail[$email] = '';
$lowercaseEmail = mb_strtolower($email);
if (! array_key_exists($lowercaseEmail, $desiredExternalGroupsByLowercaseUserEmail)) {
$desiredExternalGroupsByLowercaseUserEmail[$lowercaseEmail] = '';
}
}

foreach ($desiredExternalGroupsByUserEmail as $email => $groupsForPrefix) {
foreach ($desiredExternalGroupsByLowercaseUserEmail as $email => $groupsForPrefix) {
$user = User::findByEmail($email);
if ($user === null) {
$errors[] = 'No user found for email address ' . json_encode($email);
Expand Down
53 changes: 28 additions & 25 deletions application/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions application/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
{
"name": "google/apiclient-services",
"version": "v0.372.0"
"version": "v0.373.0"
},
{
"name": "google/auth",
Expand Down Expand Up @@ -129,7 +129,7 @@
},
{
"name": "phpseclib/phpseclib",
"version": "3.0.41"
"version": "3.0.42"
},
{
"name": "phpspec/php-diff",
Expand Down Expand Up @@ -169,7 +169,7 @@
},
{
"name": "roave/security-advisories",
"version": "dev-master 791bcaf"
"version": "dev-master cc2d3a5"
},
{
"name": "sentry/sdk",
Expand Down
16 changes: 16 additions & 0 deletions application/features/groups-external-sync.feature
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,20 @@ Feature: Syncing a specific app-prefix of external groups with an external list
| email | groups |
| [email protected] | ext-wiki-one,ext-wiki-two |

Scenario: Properly handle mismatched casing (uppercase/lowercase) in an email address
Given the following users exist, with these external groups:
| email | groups |
| [email protected] | ext-wiki-one |
| [email protected] | ext-wiki-two |
And the "ext-wiki" external groups list is the following:
| email | groups |
| [email protected] | ext-wiki-one |
| [email protected] | ext-wiki-two |
When I sync the list of "ext-wiki" external groups
Then there should not have been any sync errors
And the following users should have the following external groups:
| email | groups |
| [email protected] | ext-wiki-one |
| [email protected] | ext-wiki-two |

# Scenario: Send 1 notification email if sync finds group(s) for a user not in this IDP