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

Return correct loginname in credentials #21288

Merged
merged 2 commits into from
Aug 28, 2020
Merged

Conversation

lmamane
Copy link

@lmamane lmamane commented Jun 7, 2020

Fix #21285

@lmamane
Copy link
Author

lmamane commented Jun 7, 2020

This fixes issue #21285 but I cannot figure out how to add it to linked issue. I followed the github documentation at https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue, but:

  1. "Linked issues" is not clickable, the doc says to click there.
  2. The "fix In LDAP setup (uid != loginname), token created through getapppassword cease to function after a few minutes #21285" in the description didn't do it either.

@lmamane lmamane changed the title fix #21285 fix issue #21285 Jun 7, 2020
@lmamane lmamane changed the title fix issue #21285 fix #21285 Jun 7, 2020
@kesselb kesselb changed the title fix #21285 Return correct loginname in credentials Jun 7, 2020
@kesselb kesselb added 2. developing Work in progress bug labels Jun 7, 2020
@kesselb kesselb added this to the Nextcloud 20 milestone Jun 7, 2020
@kesselb
Copy link
Contributor

kesselb commented Jun 7, 2020

Thanks for debugging 👍

Change makes sense to me. We need some changes for the tests. I will have a look later.

@kesselb kesselb added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jun 7, 2020
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Fine from a functionality PoV, but a bit problematic in terms of code quality

Let's make it a bit less error-prone at least

lib/private/Authentication/LoginCredentials/Store.php Outdated Show resolved Hide resolved
@lmamane
Copy link
Author

lmamane commented Jun 8, 2020 via email

@kesselb
Copy link
Contributor

kesselb commented Jun 8, 2020

Then I saw this code pattern
$this->session->get('loginname')

https://github.com/nextcloud/server/blame/caff1023ea72bb2ea94130e18a2a6e2ccf819e5f/apps/encryption/lib/Controller/SettingsController.php#L116-L120

Seems the encryption app run into a similar issue before. Adding the loginName to the event sounds good but is quite hard to backport.

@lmamane
Copy link
Author

lmamane commented Jun 8, 2020

On the "hard to backport" part, we could imagine having this one-liner fix in the stable branches, and the event change in master?

@ChristophWurst
Copy link
Member

On the "hard to backport" part, we could imagine having this one-liner fix in the stable branches, and the event change in master?

Fine by me

@lmamane
Copy link
Author

lmamane commented Jun 20, 2020

On the "hard to backport" part, we could imagine having this one-liner fix in the stable branches, and the event change in master?

Fine by me

My current patch backports easily to stable19 branch. After you are happy with the current patch, let me know what version you want on stable19 (event change or "dirty" one-liner).

Copy link
Contributor

@kesselb kesselb left a comment

Choose a reason for hiding this comment

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

camelCase ;)

lib/public/User/Events/PostLoginEvent.php Outdated Show resolved Hide resolved
lib/private/Server.php Outdated Show resolved Hide resolved
lib/private/Server.php Outdated Show resolved Hide resolved
lib/private/Authentication/LoginCredentials/Store.php Outdated Show resolved Hide resolved
@lmamane lmamane requested a review from kesselb June 20, 2020 18:33
@lmamane lmamane force-pushed the master branch 2 times, most recently from e23b754 to 60cf6dc Compare June 20, 2020 20:02
@@ -47,9 +53,10 @@ class PostLoginEvent extends Event {
/**
* @since 18.0.0
*/
public function __construct(IUser $user, string $password, bool $isTokenLogin) {
public function __construct(IUser $user, string $loginName, string $password, bool $isTokenLogin) {
Copy link
Member

Choose a reason for hiding this comment

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

FYI, we cannot backport this as it breaks public API.

@MorrisJobke
Copy link
Member

My current patch backports easily to stable19 branch. After you are happy with the current patch, let me know what version you want on stable19 (event change or "dirty" one-liner).

The one liner.

@MorrisJobke
Copy link
Member

My current patch backports easily to stable19 branch. After you are happy with the current patch, let me know what version you want on stable19 (event change or "dirty" one-liner).

The one liner.

Stable19: #21779

@MorrisJobke MorrisJobke mentioned this pull request Aug 11, 2020
57 tasks
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

Lionel Elie Mamane added 2 commits August 20, 2020 16:02
even when token is invalid or has no password.

Returning the uid as loginname is wrong, and leads to problems when
these differ. E.g. the getapppassword API was creating app token with
the uid as loginname. In a scenario with external authentication (such
as LDAP), these tokens were then invalidated next time their underlying
password was checked, and systematically ceased to function.

Co-authored-by: kesselb <mail@danielkesselberg.de>
for: switch to consistent camelCase

Signed-off-by: Lionel Elie Mamane <lionel@mamane.lu>
… to uid != loginname

Signed-off-by: Lionel Elie Mamane <lionel@mamane.lu>
@MorrisJobke
Copy link
Member

Rebased to fix a conflict.

@rullzer rullzer mentioned this pull request Aug 21, 2020
19 tasks
@rullzer rullzer mentioned this pull request Aug 27, 2020
21 tasks
@rullzer rullzer merged commit 7b8364e into nextcloud:master Aug 28, 2020
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 bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In LDAP setup (uid != loginname), token created through getapppassword cease to function after a few minutes
6 participants