Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Sep 2, 2024

Summary

Backends can decide which names they accept for login, e.g. with user_ldap you can configure arbitrary login fields. This was a hacky approach to allow login via email, so instead this is now only handled by the local user backend.

This also fixes some other related problems:
Other logic relys on backend::get() which was not handling email, so e.g. password policy could not block users logged in via email if they use out-dated passwords.
Similar for other integrations, as the user backend was not consistent with what is a login name and what not.

Checklist

@susnux susnux added feature: users and groups technical debt php Pull requests that update Php code 2. developing Work in progress labels Sep 2, 2024
@susnux susnux added this to the Nextcloud 31 milestone Sep 2, 2024
private function loadUser($uid) {
$this->fixDI();
private function loadUser(string $loginName, bool $tryEmail = true): bool {
$uid = (string)$loginName;

Check failure

Code scanning / Psalm

RedundantCast

Redundant cast to string
if ($result) {
// Also add cache result for the email
$this->cache[$uid] = [
...$this->cache[$emailUId],

Check failure

Code scanning / Psalm

InvalidOperand

Cannot use spread operator on non-iterable type mixed
@susnux susnux force-pushed the fix/move-email-logic-local-user-backend branch 4 times, most recently from e7fc0bd to 5536284 Compare January 18, 2025 16:14
@susnux susnux marked this pull request as ready for review January 18, 2025 16:47
@susnux susnux added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 18, 2025
@nickvergessen
Copy link
Member

This could log out people from their instance unexpectedly when they log in with email instead of user id with LDAP. Similarly it breaks the https://github.com/nextcloud/user_external/ app users that logged in with email.

@susnux
Copy link
Contributor Author

susnux commented Jan 20, 2025

when they log in with email instead of user id with LDAP.

For LDAP we use the login attribute filter, so this should not be affected see the workaround in the removed login flow file.

it breaks the https://github.com/nextcloud/user_external/ app users that logged in with email.

This could be true but in that case we should fix that app, no?
Because it would currently only allow email login after the first UID login.
Similar as it was discussed here, though that discussion is quite old ("planned for NC14") I would still agree with the reasoning here.

But maybe we need to pause this for 32 instead?

@nickvergessen
Copy link
Member

But maybe we need to pause this for 32 instead?

Sound like a good idea to merge next week after stable31 is branched off, and then leave the user_external app an issue what they need to do

@susnux susnux modified the milestones: Nextcloud 31, Nextcloud 32 Jan 20, 2025
@susnux susnux requested a review from come-nc January 25, 2025 10:14
@susnux susnux force-pushed the fix/move-email-logic-local-user-backend branch 3 times, most recently from 7c2354d to 68a923d Compare January 31, 2025 14:46
Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane (aside from a few static-code-analysis)

@susnux

This comment was marked as resolved.

@susnux susnux force-pushed the fix/move-email-logic-local-user-backend branch from 68a923d to f4aec55 Compare February 4, 2025 17:23
Backends can decide which names they accept for login,
e.g. with user_ldap you can configure arbitrary login fields.
This was a hacky approach to allow login via email,
so instead this is now only handled by the local user backend.

This also fixes some other related problems:
Other logic relys on `backend::get()` which was not handling email,
so e.g. password policy could not block users logged in via email
if they use out-dated passwords.
Similar for other integrations, as the user backend was not consistent with
what is a login name and what not.

Co-authored-by: Ferdinand Thiessen <[email protected]>
Co-authored-by: Côme Chilliet <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux force-pushed the fix/move-email-logic-local-user-backend branch from 1945bfd to 3c4feff Compare March 3, 2025 17:02
@come-nc come-nc merged commit 2ef04bf into master Mar 4, 2025
190 checks passed
@come-nc come-nc deleted the fix/move-email-logic-local-user-backend branch March 4, 2025 17:22
@nextcloud-bot nextcloud-bot mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: users and groups php Pull requests that update Php code technical debt

Projects

None yet

5 participants