Skip to content

Commit f0865f4

Browse files
committed
added verification for exp and iss in BC-LO
Signed-off-by: Spitap <dev@asdrip.fr>
1 parent aceca5a commit f0865f4

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,17 @@ public function backChannelLogout(string $providerIdentifier, string $logout_tok
870870
);
871871
}
872872

873+
try {
874+
$discovery = $this->discoveryService->obtainDiscovery($provider);
875+
} catch (\Exception $e) {
876+
$this->logger->error('Could not reach the provider at URL ' . $provider->getDiscoveryEndpoint(), ['exception' => $e]);
877+
return $this->getBackchannelLogoutErrorResponse(
878+
'could not reach provider endpoint',
879+
'URL: ' . $provider->getDiscoveryEndpoint() . 'was not reachable',
880+
true
881+
);
882+
}
883+
873884
// decrypt the logout token
874885
$jwks = $this->discoveryService->obtainJWK($provider, $logout_token);
875886
JWT::$leeway = 60;
@@ -913,9 +924,24 @@ public function backChannelLogout(string $providerIdentifier, string $logout_tok
913924
'The logout token should contain an iss attribute',
914925
true
915926
);
927+
} elseif ($iss !== $discovery['issuer']) {
928+
return $this->getBackchannelLogoutErrorResponse(
929+
'invalid iss',
930+
'The iss of the logout token does not match the issuer',
931+
false
932+
);
916933
}
917934
$iss = $logoutTokenPayload->iss;
918935

936+
if (!isset($logoutTokenPayload->exp) || $logoutTokenPayload->exp < $this->timeFactory->getTime()) {
937+
$this->logger->debug('Logout token expired');
938+
return $this->getBackchannelLogoutErrorResponse(
939+
'invalid exp',
940+
'The logout token is expired',
941+
true
942+
);
943+
}
944+
919945
if (!isset($logoutTokenPayload->sid) && !isset($logoutTokenPayload->sub)) {
920946
return $this->getBackchannelLogoutErrorResponse(
921947
'invalid sid+sub',

0 commit comments

Comments
 (0)