Skip to content

Return correct loginname in credentials - #21288

Merged
rullzer merged 2 commits into
nextcloud:masterfrom
lmamane:master
Aug 28, 2020
Merged

Return correct loginname in credentials#21288
rullzer merged 2 commits into
nextcloud:masterfrom
lmamane:master

Conversation

@lmamane

@lmamanelmamane commented Jun 7, 2020

Copy link
Copy Markdown

@lmamane

Copy link
Copy Markdown
Author

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.

@lmamanelmamane changed the title fix #21285fix issue #21285Jun 7, 2020
@lmamanelmamane changed the title fix issue #21285fix #21285Jun 7, 2020
@kesselbkesselb changed the title fix #21285Return correct loginname in credentialsJun 7, 2020
@kesselbkesselb added 2. developing Work in progress bug labels Jun 7, 2020
@kesselbkesselb added this to the Nextcloud 20 milestone Jun 7, 2020
@kesselb

kesselb commented Jun 7, 2020

Copy link
Copy Markdown
Contributor

Thanks for debugging 👍

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

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

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

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

Comment threadlib/private/Authentication/LoginCredentials/Store.php Outdated
@lmamane

lmamane commented Jun 8, 2020 via email

Copy link
Copy Markdown
Author

@kesselb

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Author

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
Copy Markdown
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

lmamane commented Jun 20, 2020

Copy link
Copy Markdown
Author

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).

@kesselbkesselb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

camelCase ;)

Comment threadlib/public/User/Events/PostLoginEvent.php Outdated
Comment threadlib/private/Server.php Outdated
Comment threadlib/private/Server.php Outdated
Comment threadlib/private/Authentication/LoginCredentials/Store.php Outdated
@lmamane
lmamane requested a review from kesselbJune 20, 2020 18:33
@lmamane
lmamaneforce-pushed the master branch 2 times, most recently from e23b754 to 60cf6dcCompareJune 20, 2020 20:02
* @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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@MorrisJobkeMorrisJobke mentioned this pull request Aug 11, 2020
57 tasks

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

Rebased to fix a conflict.

@rullzerrullzer mentioned this pull request Aug 21, 2020
19 tasks
@rullzerrullzer mentioned this pull request Aug 27, 2020
21 tasks
@rullzer
rullzer merged commit 7b8364e into nextcloud:masterAug 28, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

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

@lmamane@kesselb@ChristophWurst@MorrisJobke@blizzz@rullzer