aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Token/PublicKeyTokenProvider.php
Commit message (Collapse)AuthorAgeFilesLines
* chore: Add proper deprecation dates where missingFerdinand Thiessen2024-09-201-1/+1
| | | | Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
* style: update codestyle for coding-standard 1.2.3Daniel Kesselberg2024-08-251-9/+9
| | | | Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
* feat(auth): Clean-up unused auth tokens and wipe tokensChristoph Wurst2024-08-131-2/+11
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* fix(Token): take over scope in token refresh with login by cookieArthur Schiwon2024-07-191-3/+11
| | | | Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
* fix(Session): avoid race conditions on clustered setupsArthur Schiwon2024-07-101-1/+1
| | | | | | | | - re-stablishes old behaviour with cache to return null instead of throwing an InvalidTokenException when the token is cached as non-existing - token invalidation and re-generation are bundled in a DB transaction now Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
* fix(Session): avoid password confirmation on SSOArthur Schiwon2024-06-051-0/+1
| | | | | | | | | | | SSO backends like SAML and OIDC tried a trick to suppress password confirmations as they are not possible by design. At least for SAML it was not reliable when existing user backends where used as user repositories. Now we are setting a special scope with the token, and also make sure that the scope is taken over when tokens are regenerated. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
* Merge pull request #45411 from ↵Daniel2024-05-291-2/+0
|\ | | | | | | | | nextcloud/fix/auth/selective-token-activity-update fix(auth): Update authtoken activity selectively
| * fix(auth): Update authtoken activity selectivelyChristoph Wurst2024-05-211-2/+0
| | | | | | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* | chore: Add SPDX headerAndy Scherzinger2024-05-241-24/+2
|/ | | | Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
* Merge pull request #45026 from nextcloud/fix/token-updateChristoph Wurst2024-05-161-0/+2
|\ | | | | Avoid updating the same oc_authtoken row twice
| * fix: Always set last activity if we update the row of an authtoken anywaysJulius Härtl2024-04-291-0/+2
| | | | | | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* | fix(session): Avoid race condition for cache::get() vs. cache::hasKey()Joas Schilling2024-04-291-6/+6
|/ | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* fix: Apply new coding standard to all filesCôme Chilliet2024-04-021-1/+1
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* feat(perf): add cache for authtoken lookupBenjamin Gaussorgues2024-02-281-58/+73
| | | | Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
* Import OCP IToken as OCPIToken to avoid a name clash in lib/privateCôme Chilliet2024-01-111-17/+17
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Use IToken from OCP instead of OCCôme Chilliet2024-01-111-0/+1
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* chore: apply changes from Nextcloud coding standards 1.1.1Joas Schilling2023-11-231-21/+21
| | | | | Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
* Add last-used-before optionLucas Azevedo2023-08-251-0/+6
| | | | Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
* Merge branch 'master' into enh/type-iconfig-getter-callsCôme Chilliet2023-04-201-51/+55
|\ | | | | Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
| * fix(auth): Run token statements in atomic transactionChristoph Wurst2023-04-121-51/+55
| | | | | | | | | | | | All or nothing Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* | Use typed version of IConfig::getSystemValue as much as possibleCôme Chilliet2023-04-051-5/+5
|/ | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Don't try to hash a nonexisting passwordEmber 'n0emis' Keske2023-03-131-1/+1
| | | | | | Allows to log-in via a passwordless authentication provider, eg SSO Signed-off-by: Ember 'n0emis' Keske <git@n0emis.eu>
* fix(authentication): Handle null or empty string password hashJoas Schilling2023-02-101-1/+1
| | | | | | | | This can happen when the auth.storeCryptedPassword config is used, which previously errored with: Hasher::verify(): Argument #2 ($hash) must be of type string, null given Signed-off-by: Joas Schilling <coding@schilljs.com>
* Merge pull request #36621 from ↵Joas Schilling2023-02-101-1/+30
|\ | | | | | | | | nextcloud/perf/noid/only-check-for-token-when-it-can-actually-be fix(performance): Only search for auth tokens when the provided login…
| * fix(authentication): Check minimum length when creating app tokensJoas Schilling2023-02-091-2/+10
| | | | | | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
| * fix(performance): Only search for auth tokens when the provided login is ↵Joas Schilling2023-02-081-1/+22
| | | | | | | | | | | | long enough Signed-off-by: Joas Schilling <coding@schilljs.com>
* | fix(authtoken): Store only one hash for authtokens with the current password ↵Julius Härtl2023-02-091-1/+23
|/ | | | | | per user Signed-off-by: Julius Härtl <jus@bitgrid.net>
* fix(authentication): Update the token when the hash is null or can not be ↵Joas Schilling2023-01-091-4/+21
| | | | | | verified Signed-off-by: Joas Schilling <coding@schilljs.com>
* fix(authentication): Only hash the new password when neededJoas Schilling2023-01-091-2/+6
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* fix(authentication): Invert the logic to the original intentionJoas Schilling2023-01-091-2/+3
| | | | | | | We need to store the new authentication details when the hash did **not** verify the old password. Signed-off-by: Joas Schilling <coding@schilljs.com>
* fix(authentication): Only verify each hash onceJoas Schilling2023-01-091-2/+4
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Merge pull request #33898 from nextcloud/fix/authtoken-password-updateJulius Härtl2023-01-051-4/+16
|\ | | | | PublickKeyTokenProvider: Fix password update routine with password hash
| * PublickKeyTokenProvider: Fix password update routine with password hashMarcel Klehr2023-01-041-4/+16
| | | | | | | | Signed-off-by: Marcel Klehr <mklehr@gmx.net>
* | Add a const for the max user password lengthJoas Schilling2023-01-041-1/+2
|/ | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Run session token renewals in a database transactionChristoph Wurst2022-10-181-23/+32
| | | | | | | | | | | | | The session token renewal does 1) Read the old token 2) Write a new token 3) Delete the old token If two processes succeed to read the old token there can be two new tokens because the queries were not run in a transaction. This is particularly problematic on clustered DBs where 1) would go to a read node and 2) and 3) go to a write node. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Merge pull request #31499 from nextcloud/bugfix/empty-secretCarl Schwan2022-10-171-5/+24
|\ | | | | Add fallback routines for empty secret cases
| * Mark method as deprecatedCarl Schwan2022-09-131-1/+1
| | | | | | | | Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: Carl Schwan <carl@carlschwan.eu>
| * Rotate token after fallbackJulius Härtl2022-03-101-2/+8
| | | | | | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
| * Add fallback routines for empty secret casesJulius Härtl2022-03-101-3/+16
| | | | | | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* | Do not update passwords if nothing changedJulius Härtl2022-08-091-3/+6
| | | | | | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* | Merge pull request #33225 from nextcloud/fix/handle-one-time-passwordsCarl Schwan2022-07-291-1/+1
|\ \ | | | | | | Handle one time password better
| * | Handle one time password betterCarl Schwan2022-07-281-1/+1
| | | | | | | | | | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | | Move CappedMemoryCache to OCPCarl Schwan2022-07-141-1/+1
|/ / | | | | | | | | | | | | | | This is an helpful helper that should be used in more place than just server and this is already the case with groupfodlers, deck, user_oidc and more using it, so let's make it public Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Handler large passwordsCarl Schwan2022-07-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | For passwords bigger than 250 characters, use a bigger key since the performance impact is minor (around one second to encrypt the password). For passwords bigger than 470 characters, give up earlier and throw exeception recommanding admin to either enable the previously enabled configuration or use smaller passwords. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Handle one time passwordsCarl Schwan2022-07-051-1/+1
| | | | | | | | | | | | | | | | This adds an option to disable storing passwords in the database. This might be desirable when using single use token as passwords or very large passwords. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Fix user agent trimming on installationJoas Schilling2022-05-091-1/+1
| | | | | | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* | Limit the length of app password namesJoas Schilling2022-03-231-0/+4
|/ | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Also cache non-existing to reuse itJoas Schilling2022-02-161-0/+5
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Remove default token which is deprecated since Nextcloud 13Joas Schilling2021-12-011-24/+0
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Prevent duplicate auth token activity updatesChristoph Wurst2021-10-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The auth token activity logic works as follows * Read auth token * Compare last activity time stamp to current time * Update auth token activity if it's older than x seconds This works fine in isolation but with concurrency that means that occasionally the same token is read simultaneously by two processes and both of these processes will trigger an update of the same row. Affectively the second update doesn't add much value. It might set the time stamp to the exact same time stamp or one a few seconds later. But the last activity is no precise science, we don't need this accuracy. This patch changes the UPDATE query to include the expected value in a comparison with the current data. This results in an affected row when the data in the DB still has an old time stamp, but won't affect a row if the time stamp is (nearly) up to date. This is a micro optimization and will possibly not show any significant performance improvement. Yet in setups with a DB cluster it means that the write node has to send fewer changes to the read nodes due to the lower number of actual changes. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>