summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2023-11-07 09:13:48 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-02-09 11:10:28 +0100
commitbcd7d59a20183c76164ceab59366bde1d3a74cff (patch)
tree0e94287a4133bdf317993afdc795c35228670c40 /lib
parentdb8252e82c4efbd37195a264654b4246f79ca62d (diff)
downloadnextcloud-server-bcd7d59a20183c76164ceab59366bde1d3a74cff.tar.gz
nextcloud-server-bcd7d59a20183c76164ceab59366bde1d3a74cff.zip
fix(session): Do not log fresh/empty session as error
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Session/CryptoSessionData.php30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/private/Session/CryptoSessionData.php b/lib/private/Session/CryptoSessionData.php
index 76a214584a6..ae4b80209d5 100644
--- a/lib/private/Session/CryptoSessionData.php
+++ b/lib/private/Session/CryptoSessionData.php
@@ -32,6 +32,7 @@ namespace OC\Session;
use OCP\ISession;
use OCP\Security\ICrypto;
use OCP\Session\Exceptions\SessionNotAvailableException;
+use function json_decode;
use function OCP\Log\logger;
/**
@@ -80,19 +81,24 @@ class CryptoSessionData implements \ArrayAccess, ISession {
protected function initializeSession() {
$encryptedSessionData = $this->session->get(self::encryptedSessionName) ?: '';
- try {
- $this->sessionValues = json_decode(
- $this->crypto->decrypt($encryptedSessionData, $this->passphrase),
- true,
- 512,
- JSON_THROW_ON_ERROR,
- );
- } catch (\Exception $e) {
- logger('core')->critical('Could not decrypt or decode encrypted session data', [
- 'exception' => $e,
- ]);
+ if ($encryptedSessionData === '') {
+ // Nothing to decrypt
$this->sessionValues = [];
- $this->regenerateId(true, false);
+ } else {
+ try {
+ $this->sessionValues = json_decode(
+ $this->crypto->decrypt($encryptedSessionData, $this->passphrase),
+ true,
+ 512,
+ JSON_THROW_ON_ERROR,
+ );
+ } catch (\Exception $e) {
+ logger('core')->critical('Could not decrypt or decode encrypted session data', [
+ 'exception' => $e,
+ ]);
+ $this->sessionValues = [];
+ $this->regenerateId(true, false);
+ }
}
}