-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix(dav): return 401 instead of 503 for disabled user login attempts #58804
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| use Exception; | ||
| use OC\Authentication\Exceptions\PasswordLoginForbiddenException; | ||
| use OC\Authentication\TwoFactorAuth\Manager; | ||
| use OC\User\LoginException; | ||
| use OC\User\Session; | ||
| use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden; | ||
| use OCA\DAV\Connector\Sabre\Exception\TooManyRequests; | ||
|
|
@@ -109,6 +110,9 @@ public function check(RequestInterface $request, ResponseInterface $response) { | |
| return $this->auth($request, $response); | ||
| } catch (NotAuthenticated $e) { | ||
| throw $e; | ||
| } catch (LoginException $e) { | ||
| Server::get(LoggerInterface::class)->info($e->getMessage(), ['exception' => $e]); | ||
| throw new NotAuthenticated($e->getMessage(), 0, $e); | ||
|
Comment on lines
+114
to
+115
|
||
| } catch (Exception $e) { | ||
| $class = get_class($e); | ||
| $msg = $e->getMessage(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a LoginException bubbles up from validateUserPass()/auth(), the PHP session may still be open (validateUserPass() does not close the session on LoginException). This catch block converts the exception but doesn't close the session either, which can keep the session lock held longer than necessary and potentially slow down concurrent requests. Call $this->session->close() (ideally in a finally or at least before logging/throwing) on this path as well.