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

Do not update passwords if nothing changed #33485

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Aug 8, 2022

This would avoid updating the password on all authtokens if nothing has changed.

It may especially result in heavy requests when using the user password to authenticate through basic auth, where then every request would trigger an update of all tokens.

Screenshot 2022-08-08 at 17 45 54

Todo

  • Check if an additional transation might be worth to add
  • Check if we can otherwise batch the operation or perform filtering upfront (e.g. for passwordless tokens)

@juliusknorr juliusknorr requested review from nickvergessen, ChristophWurst, a team, PVince81, skjnldsv and come-nc and removed request for a team August 8, 2022 15:56
@juliusknorr
Copy link
Member Author

I'll skip adding a transaction as the 99% case should be that no update is performed at all (as the password didn't change).

Furthermore preliminary filtering is also not very suitable, as it would require filter by the password field. We could add a debounce to only check and update the passwords very n minutes, but that may then lead to outdated tokens that could not reliably be updated with the most recent password.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliusknorr juliusknorr marked this pull request as ready for review August 9, 2022 07:35
@juliusknorr juliusknorr force-pushed the bugfix/noid/authtoken-duplicate-update branch from a71e9f3 to 9d1ec58 Compare August 9, 2022 07:35
@juliusknorr
Copy link
Member Author

Rebased and squashed, tests seemed to be happy already.

@juliusknorr juliusknorr added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Aug 9, 2022
@juliusknorr juliusknorr merged commit 7992a3e into master Aug 9, 2022
@juliusknorr juliusknorr deleted the bugfix/noid/authtoken-duplicate-update branch August 9, 2022 18:38
@juliusknorr
Copy link
Member Author

/backport to stable24

@juliusknorr
Copy link
Member Author

/backport to stable23

@not-implemented
Copy link

not-implemented commented Aug 13, 2022

Many thanks! ... I just started debugging, why my MySQL binlogs are so big ... and I saw all those UPDATE oc_authtoken SET password = ... querys ;-)

@nickvergessen
Copy link
Member

/backport to stable22

@Mask
Copy link

Mask commented Aug 28, 2022

Has anyone verified if this has any effect?

I just installed 23.0.8 and still see all the user's oc_authtokens being updated on basic auth requests.

My theory: this patch compares the saved encrypted password with the newly generated encrypted password. What it does not take into account is that openssl_public_encrypt outputs a different ciphertext every time, even on identical input values.

see https://stackoverflow.com/a/2980121 for an explanation.

@juliusknorr
Copy link
Member Author

Thanks for letting us know. I'm unsure on why this didn't show up in my tests, as I managed to not get the updates on my dev instance and also did profiling for comparison, but with a simple php example I can confirm that we need to check the clear text password for that.

I'll have another look into that.

@Mask
Copy link

Mask commented Aug 29, 2022

or the hashed password. Hashes are stable too (if the salt is identical, of course)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish performance 🚀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants