summaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication
Commit message (Collapse)AuthorAgeFilesLines
* Adapt tests to config value typingCôme Chilliet2023-04-052-5/+12
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* unit tests for Manager::invalidateTokensOfUserArtur Neumann2023-03-141-0/+44
| | | | Signed-off-by: Artur Neumann <artur@jankaritech.com>
* Fix unit testsJoas Schilling2023-02-091-47/+42
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* composer run cs:fixCôme Chilliet2023-01-2028-29/+0
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* PublickKeyTokenProvider: Fix password update routine with password hashMarcel Klehr2023-01-041-0/+2
| | | | Signed-off-by: Marcel Klehr <mklehr@gmx.net>
* Fix PublicKeyTokenProviderTest import and mockChristoph Wurst2022-11-101-4/+2
| | | | | | | * IDBConnection import missing * Atomic doesn't need a mock Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Skip general login with email for non-valid addresses and LDAPJulius Härtl2022-10-261-2/+3
| | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* Run session token renewals in a database transactionChristoph Wurst2022-10-181-2/+18
| | | | | | | | | | | | | 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-3/+15
|\ | | | | Add fallback routines for empty secret cases
| * Fix unit testsCarl Schwan2022-03-101-3/+15
| | | | | | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Handle one time password betterCarl Schwan2022-07-281-1/+9
| | | | | | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Handler large passwordsCarl Schwan2022-07-051-0/+19
| | | | | | | | | | | | | | | | | | | | | | 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-4/+56
| | | | | | | | | | | | | | | | 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-2/+7
| | | | | | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* | Automatically cut the token name on the first levelJoas Schilling2022-03-231-0/+31
| | | | | | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* | Fix unit testsJoas Schilling2022-03-232-73/+58
|/ | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* More test fixingJoas Schilling2021-12-012-4/+0
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* More test fixingJoas Schilling2021-12-012-235/+6
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* More unit test adjustmentsJoas Schilling2021-12-014-878/+0
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Fix test class namesCôme Chilliet2021-11-232-2/+2
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Prevent duplicate auth token activity updatesChristoph Wurst2021-10-221-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix Authentication testJoas Schilling2021-04-221-4/+5
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Move 2FA registration to IBootstrapRoeland Jago Douma2021-04-201-1/+38
| | | | Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Fix unit testRoeland Jago Douma2021-04-1613-15/+14
| | | | | | | | | * Fix namespace * Fix test Was broken after https://github.com/nextcloud/server/pull/26529 Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Add real events for enabled 2fa providers for usersRoeland Jago Douma2021-03-221-0/+7
| | | | | | | * Shiny new events * Listener to still emit the old event Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Always renew apppasswords on loginRoeland Jago Douma2021-02-101-17/+1
| | | | | | | | Else you can end up that you renewed your password (LDAP for example). But they still don't work because you did not use them before you logged in. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Convert 2FA token type to stringChristoph Wurst2021-01-221-5/+5
| | | | | | | | The IConfig service is documented to handle its data as strings, hence this changes the code a bit to ensure we store keys as string and convert them back when reading. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Use PSR logger in authenticationJoas Schilling2020-10-1210-36/+35
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Format code to a single space around binary operatorsChristoph Wurst2020-10-053-4/+4
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Allow configuring the activity update interval of tokenRoeland Jago Douma2020-10-041-0/+6
| | | | | | | | On some systems with a lot of users this creates a lot of extra DB writes. Being able to increase this interval helps there. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Fix undefined class property access after upgrade from 19 to 20Christoph Wurst2020-09-071-0/+76
| | | | | | | | | The serialized data in 19 has one property less and this was not considered in the code. Hence adding a fallback. Moreover I'm changing the deserialization into an array instead of object, as that is the safer option. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* adapt testGetLoginCredentialsInvalidTokenLoginCredentials() unit test to uid ↵Lionel Elie Mamane2020-08-201-3/+4
| | | | | | != loginname Signed-off-by: Lionel Elie Mamane <lionel@mamane.lu>
* Merge pull request #21344 from nextcloud/fix/twofactor-cleanup-eventMorris Jobke2020-08-132-6/+30
|\ | | | | Emit an event for every disabled 2FA provider during cleanup
| * Emit an event for every disabled 2FA provider during cleanupChristoph Wurst2020-06-162-6/+30
| | | | | | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* | Change PHPDoc type hint from PHPUnit_Framework_MockObject_MockObject to ↵Morris Jobke2020-08-126-35/+33
|/ | | | | | \PHPUnit\Framework\MockObject\MockObject Signed-off-by: Morris Jobke <hey@morrisjobke.de>
* Clean up auth tokens when user is deletedChristoph Wurst2020-06-151-0/+117
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Do not create remember me cookieJulius Härtl2020-04-231-1/+24
| | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* Format control structures, classes, methods and functionChristoph Wurst2020-04-1033-36/+0
| | | | | | | | | | | | | | | To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Use elseif instead of else ifChristoph Wurst2020-04-101-1/+1
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Unify function spacing to PSR2 recommendationChristoph Wurst2020-04-093-6/+6
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Use a blank line after the opening tagChristoph Wurst2020-04-0913-8/+29
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Fix multiline commentsChristoph Wurst2020-04-081-1/+0
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* [POC] Event for failed login attemptsRoeland Jago Douma2020-03-311-1/+8
| | | | Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Merge pull request #20170 from nextcloud/techdebt/remove-unused-importsChristoph Wurst2020-03-276-6/+0
|\ | | | | Remove unused imports
| * Remove unused importsChristoph Wurst2020-03-256-6/+0
| | | | | | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* | Use the shorter phpunit syntax for mocked return valuesChristoph Wurst2020-03-254-28/+28
|/ | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Check the user on remote wipeJoas Schilling2020-03-161-13/+3
| | | | Signed-off-by: Joas Schilling <coding@schilljs.com>
* Clean up 2FA provider registry when a user is deletedChristoph Wurst2020-01-082-0/+24
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Mode to modern phpunitRoeland Jago Douma2019-11-276-46/+46
| | | | Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Make phpunit8 compatibleRoeland Jago Douma2019-11-2731-31/+31
| | | | Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>