Skip to content

Commit af7136a

Browse files
committed
Require jti on back-channel logout, add jti getter
1 parent 8e22a51 commit af7136a

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

src/OpenIDConnectClient.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ class OpenIDConnectClient
278278
*/
279279
private $backChannelSubject;
280280

281+
/**
282+
* @var string jti (JWT ID) of back-channel logout it will be stored here
283+
*/
284+
private $backChannelJti;
285+
281286
/**
282287
* @var array list of supported auth methods
283288
*/
@@ -612,6 +617,23 @@ public function verifyLogoutToken(): bool
612617
// Verify Logout Token Claims
613618
if ($this->verifyLogoutTokenClaims($claims)) {
614619
$this->verifiedClaims = $claims;
620+
621+
// Set the sid, which could be used to map to a session in
622+
// the RP, and therefore be used to help destroy the RP's
623+
// session.
624+
if (isset($claims->sid)) {
625+
$this->backChannelSid = $claims->sid;
626+
}
627+
628+
// Set the sub, which could be used to map to a session in
629+
// the RP, and therefore be used to help destroy the RP's
630+
// session.
631+
if (isset($claims->sub)) {
632+
$this->backChannelSubject = $claims->sub;
633+
}
634+
635+
$this->backChannelJti = $claims->jti;
636+
615637
return true;
616638
}
617639

@@ -631,7 +653,6 @@ public function verifyLogoutToken(): bool
631653
public function verifyLogoutTokenClaims(object $claims): bool
632654
{
633655
try {
634-
635656
$clock = new Clock();
636657
$claimCheckerManager = new ClaimCheckerManager(
637658
[
@@ -658,19 +679,6 @@ public function verifyLogoutTokenClaims(object $claims): bool
658679
if (!isset($claims->sid) && !isset($claims->sub)) {
659680
return false;
660681
}
661-
// Set the sid, which could be used to map to a session in
662-
// the RP, and therefore be used to help destroy the RP's
663-
// session.
664-
if (isset($claims->sid)) {
665-
$this->backChannelSid = $claims->sid;
666-
}
667-
668-
// Set the sub, which could be used to map to a session in
669-
// the RP, and therefore be used to help destroy the RP's
670-
// session.
671-
if (isset($claims->sub)) {
672-
$this->backChannelSubject = $claims->sub;
673-
}
674682

675683
return true;
676684
}
@@ -877,7 +885,6 @@ protected function generateRandString(): string
877885
*/
878886
private function requestAuthorization()
879887
{
880-
881888
$auth_endpoint = $this->getProviderConfigValue('authorization_endpoint');
882889
$response_type = 'code';
883890

@@ -2194,6 +2201,11 @@ public function getSubjectFromBackChannel(): string
21942201
return $this->backChannelSubject;
21952202
}
21962203

2204+
public function getJtiFromBackChannel(): string
2205+
{
2206+
return $this->backChannelJti;
2207+
}
2208+
21972209
public function supportsAuthMethod(string $auth_method, array $token_endpoint_auth_methods_supported): bool
21982210
{
21992211
# client_secret_jwt has to explicitly be enabled

0 commit comments

Comments
 (0)