-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(session): Avoid useless authtoken DB queries for anonymous requests #42607
Conversation
lib/private/User/Session.php
Outdated
$instanceId = $this->config->getSystemValueString('instanceid'); | ||
if (is_null($request->getCookie($instanceId))) { | ||
return false; | ||
} |
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.
Without looking in depth, just from the following code lines I think that this could have unexpected side effects when just authenticating with an app password which is also a token but not necessarily has cookies if clients send it.
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.
Adjusted so that the token lookup by session id only happens if there is neither an Authrorization header nor session cookie
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.
/backport to stable28 |
/backport to stable27 |
/backport to stable26 |
lib/private/User/Session.php
Outdated
@@ -842,13 +842,16 @@ public function tryTokenLogin(IRequest $request) { | |||
$authHeader = $request->getHeader('Authorization'); | |||
if (str_starts_with($authHeader, 'Bearer ')) { | |||
$token = substr($authHeader, 7); | |||
} else { | |||
// No auth header, let's try session id | |||
} else if ($request->getCookie($this->config->getSystemValueString('instanceid')) !== null) { |
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.
} else if ($request->getCookie($this->config->getSystemValueString('instanceid')) !== null) { | |
} elseif ($request->getCookie($this->config->getSystemValueString('instanceid')) !== null) { |
…ous request Co-Authored-By: Christoph Wurst <christoph@winzerhof-wurst.at> Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
5e342b6
to
72e0618
Compare
Checklist