Skip to content

Commit 9cbbf5b

Browse files
Merge pull request #62110 from nextcloud/backport/61981/stable33
[stable33] fix(UserPlugin): Don't return mail matches on user id search
2 parents 49b4871 + e779db0 commit 9cbbf5b

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

build/integration/sharees_features/sharees.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,40 @@ Feature: sharees
426426
And "exact emails" sharees returned is empty
427427
And "emails" sharees returned is empty
428428

429+
Scenario: Search user by system e-mail address with e-mail full match disabled
430+
Given As an "test"
431+
And parameter "shareapi_restrict_user_enumeration_full_match_email" of app "core" is set to "no"
432+
When getting sharees for
433+
| search | sharee2@system.com |
434+
| itemType | file |
435+
| shareType | 0 |
436+
Then the OCS status code should be "100"
437+
And the HTTP status code should be "200"
438+
And "exact users" sharees returned is empty
439+
# With enumeration allowed the user is still found as non-exact match, as
440+
# enumeration also searches in the e-mail address
441+
And "users" sharees returned are
442+
| Sharee2 | 0 | Sharee2 | sharee2@system.com |
443+
And "exact emails" sharees returned is empty
444+
And "emails" sharees returned is empty
445+
446+
Scenario: Search user by system e-mail address with e-mail full match and user enumeration disabled
447+
Given As an "test"
448+
And parameter "shareapi_restrict_user_enumeration_full_match_email" of app "core" is set to "no"
449+
And parameter "shareapi_allow_share_dialog_user_enumeration" of app "core" is set to "no"
450+
When getting sharees for
451+
| search | sharee2@system.com |
452+
| itemType | file |
453+
| shareType | 0 |
454+
Then the OCS status code should be "100"
455+
And the HTTP status code should be "200"
456+
# The user id full match must not resolve e-mail addresses through the user
457+
# backends (login via e-mail address)
458+
And "exact users" sharees returned is empty
459+
And "users" sharees returned is empty
460+
And "exact emails" sharees returned is empty
461+
And "emails" sharees returned is empty
462+
429463
Scenario: Search e-mail
430464
Given As an "test"
431465
When getting sharees for

lib/private/Collaboration/Collaborators/UserPlugin.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b
102102

103103
if ($shareeEnumerationFullMatchUserId) {
104104
$user = $this->userManager->get($search);
105-
if ($user !== null) {
105+
// User backends may also resolve email addresses or other login names here
106+
// (e.g. for login via email). Only an actual user id match counts as user id
107+
// full match, everything else is governed by the email setting below.
108+
if ($user !== null && mb_strtolower($user->getUID()) === $lowerSearch) {
106109
$users[$user->getUID()] = ['exact', $user];
107110
}
108111
}

0 commit comments

Comments
 (0)