summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-01-06 09:03:59 +0100
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2024-01-17 09:27:17 +0000
commit27af03c92d1eea2c7c8e19b1f0b3646633173642 (patch)
tree5747723f3dd3a6740a5113d3785478ae900d5eb8 /lib
parente2056a1de95dda2d7d1824e6b050e9369a048ca6 (diff)
downloadnextcloud-server-27af03c92d1eea2c7c8e19b1f0b3646633173642.tar.gz
nextcloud-server-27af03c92d1eea2c7c8e19b1f0b3646633173642.zip
fix(session): Avoid two useless authtoken DB queries for every anonymous 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>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/User/Session.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php
index de4d1f63b9e..78b4778bd52 100644
--- a/lib/private/User/Session.php
+++ b/lib/private/User/Session.php
@@ -840,13 +840,16 @@ class Session implements IUserSession, Emitter {
$authHeader = $request->getHeader('Authorization');
if (strpos($authHeader, 'Bearer ') === 0) {
$token = substr($authHeader, 7);
- } else {
- // No auth header, let's try session id
+ } elseif ($request->getCookie($this->config->getSystemValueString('instanceid')) !== null) {
+ // No auth header, let's try session id, but only if this is an existing
+ // session and the request has a session cookie
try {
$token = $this->session->getId();
} catch (SessionNotAvailableException $ex) {
return false;
}
+ } else {
+ return false;
}
if (!$this->loginWithToken($token)) {