Skip to content

Commit 302aee6

Browse files
committed
re-add possible Exceptions and clearer logging
1 parent 149ded7 commit 302aee6

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use OCP\AppFramework\Utility\ITimeFactory;
4747
use OCP\Authentication\Exceptions\InvalidTokenException;
4848
use OCP\Authentication\Token\IToken;
49+
use OCP\DB\Exception;
4950
use OCP\EventDispatcher\IEventDispatcher;
5051
use OCP\IAppConfig;
5152
use OCP\IConfig;
@@ -852,6 +853,8 @@ public function singleLogoutService() {
852853
*
853854
* @param string $providerIdentifier
854855
* @param string $logout_token
856+
* @throws Exception
857+
* @throws \JsonException
855858
* @return JSONResponse
856859
*/
857860
#[PublicPage]
@@ -928,18 +931,24 @@ public function backChannelLogout(string $providerIdentifier, string $logout_tok
928931
$sid = $logoutTokenPayload->sid;
929932
$sub = $logoutTokenPayload->sub ?? null;
930933
try {
931-
$oidcSession = $this->sessionMapper->findSessionBySid($sid, $sub, $iss);
932-
$oidcSessionsToKill[] = $oidcSession;
934+
$oidcSessionsToKill[] = $this->sessionMapper->findSessionBySid($sid, $sub, $iss);
933935
} catch (DoesNotExistException $e) {
934-
$this->logger->debug("[BackchannelLogout] OIDC session not found (expected for a RP-initiated logout)");
936+
$this->logger->debug('[BackchannelLogout] OIDC session not found with sid+sub+iss (expected for a RP-initiated logout)');
937+
} catch (MultipleObjectsReturnedException $e) {
938+
$this->logger->warning('[BackchannelLogout] Multiple OIDC sessions retrieved (sid+sub+iss). ' .
939+
'This should not happen. Please check that you have created your DB indexes')
935940
}
936941
} else {
937942
// here we know the sid is not set so the sub is set
938943
$sub = $logoutTokenPayload->sub;
939944
try {
940-
$oidcSessionsToKill = $this->sessionMapper->findSessionsBySubAndIss($sub, $iss);
941-
} catch (DoesNotExistException $e) {
942-
$this->logger->debug("[BackchannelLogout] OIDC session not found (expected for a RP-initiated logout)");
945+
$oidcSessionsToKill[] = $this->sessionMapper->findSessionsBySubAndIss($sub, $iss);
946+
} catch (\OCP\Db\Exception $e) {
947+
$this->logger->debug('[BackchannelLogout] Database failure while trying to retrieve user session (sub+iss)');
948+
}
949+
950+
if (empty($oidcSessionsToKill)) {
951+
$this->logger->debug('[BackchannelLogout] OIDC session not found with sub+iss (expected for a RP-initiated logout)');
943952
}
944953
}
945954

0 commit comments

Comments
 (0)