Skip to content

Commit 7c0b1d3

Browse files
committed
return a success on missing session during BC-LO
see #1430 Signed-off-by: Spitap <dev@asdrip.fr>
1 parent 4aaac7a commit 7c0b1d3

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
use OCP\AppFramework\Utility\ITimeFactory;
4747
use OCP\Authentication\Exceptions\InvalidTokenException;
4848
use OCP\Authentication\Token\IToken;
49-
use OCP\DB\Exception;
5049
use OCP\EventDispatcher\IEventDispatcher;
5150
use OCP\IAppConfig;
5251
use OCP\IConfig;
@@ -846,13 +845,14 @@ public function singleLogoutService() {
846845
* Endpoint called by the IdP (OP) when end_session_endpoint is called by another client
847846
* The logout token contains the sid for which we know the sessionId
848847
* which leads to the auth token that we can invalidate
848+
* In a RP-initiated logout scenario
849+
* the invalidation step should not be required since it would have been cleared
850+
* in singleLogoutService()
849851
* Implemented according to https://openid.net/specs/openid-connect-backchannel-1_0.html
850852
*
851853
* @param string $providerIdentifier
852854
* @param string $logout_token
853855
* @return JSONResponse
854-
* @throws Exception
855-
* @throws \JsonException
856856
*/
857857
#[PublicPage]
858858
#[NoCSRFRequired]
@@ -929,39 +929,17 @@ public function backChannelLogout(string $providerIdentifier, string $logout_tok
929929
$sub = $logoutTokenPayload->sub ?? null;
930930
try {
931931
$oidcSession = $this->sessionMapper->findSessionBySid($sid, $sub, $iss);
932+
$oidcSessionsToKill[] = $oidcSession;
932933
} catch (DoesNotExistException $e) {
933-
return $this->getBackchannelLogoutErrorResponse(
934-
$sub === null ? 'invalid SID or ISS' : 'invalid SID, SUB or ISS',
935-
$sub === null ? 'No session was found for this (sid,iss)' : 'No session was found for this (sid,sub,iss)',
936-
['session_not_found' => $sid]
937-
);
938-
} catch (MultipleObjectsReturnedException $e) {
939-
return $this->getBackchannelLogoutErrorResponse(
940-
$sub === null ? 'invalid SID or ISS' : 'invalid SID, SUB or ISS',
941-
$sub === null ? 'Multiple sessions were found with this (sid,iss)' : 'Multiple sessions were found with this (sid,sub,iss)',
942-
['multiple_sessions_found' => $sid]
943-
);
934+
$this->logger->debug("[BackchannelLogout] OIDC session not found (expected for a RP-initiated logout)");
944935
}
945-
$oidcSessionsToKill[] = $oidcSession;
946936
} else {
947937
// here we know the sid is not set so the sub is set
948938
$sub = $logoutTokenPayload->sub;
949939
try {
950940
$oidcSessionsToKill = $this->sessionMapper->findSessionsBySubAndIss($sub, $iss);
951-
} catch (\OCP\Db\Exception $e) {
952-
return $this->getBackchannelLogoutErrorResponse(
953-
'error with sub+iss',
954-
'Failed to retrieve session with sub+iss',
955-
['sub_iss_error' => true]
956-
);
957-
}
958-
959-
if (empty($oidcSessionsToKill)) {
960-
return $this->getBackchannelLogoutErrorResponse(
961-
'nothing found with sub+iss',
962-
'No session found with sub+iss',
963-
['sub_iss_no_session_found' => true]
964-
);
941+
} catch (DoesNotExistException $e) {
942+
$this->logger->debug("[BackchannelLogout] OIDC session not found (expected for a RP-initiated logout)");
965943
}
966944
}
967945

0 commit comments

Comments
 (0)