From 1a6fe332823c4127d9e0273e996326d42a6c4b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ivan=C4=8Di=C4=87?= Date: Mon, 20 May 2024 15:54:10 +0200 Subject: [PATCH] Accommodate for new immutable behavior of Builder --- src/Services/IdTokenBuilder.php | 28 ++++++++++++++-------------- src/Services/LogoutTokenBuilder.php | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Services/IdTokenBuilder.php b/src/Services/IdTokenBuilder.php index ad03b38c..d9449dcb 100644 --- a/src/Services/IdTokenBuilder.php +++ b/src/Services/IdTokenBuilder.php @@ -48,15 +48,15 @@ public function build( $builder = $this->getBuilder($accessToken, $userEntity); if (null !== $nonce) { - $builder->withClaim('nonce', $nonce); + $builder = $builder->withClaim('nonce', $nonce); } if (null !== $authTime) { - $builder->withClaim('auth_time', $authTime); + $builder = $builder->withClaim('auth_time', $authTime); } if ($addAccessTokenHash) { - $builder->withClaim( + $builder = $builder->withClaim( 'at_hash', $this->generateAccessTokenHash( $accessToken, @@ -66,11 +66,11 @@ public function build( } if (null !== $acr) { - $builder->withClaim('acr', $acr); + $builder = $builder->withClaim('acr', $acr); } if (null !== $sessionId) { - $builder->withClaim('sid', $sessionId); + $builder = $builder->withClaim('sid', $sessionId); } // Need a claim factory here to reduce the number of claims by provided scope. @@ -92,36 +92,36 @@ public function build( if (is_array($claimValue)) { /** @psalm-suppress MixedAssignment */ foreach ($claimValue as $aud) { - $builder->permittedFor((string)$aud); + $builder = $builder->permittedFor((string)$aud); } } else { - $builder->permittedFor((string)$claimValue); + $builder = $builder->permittedFor((string)$claimValue); } break; case RegisteredClaims::EXPIRATION_TIME: /** @noinspection PhpUnnecessaryStringCastInspection */ - $builder->expiresAt(new DateTimeImmutable('@' . (string)$claimValue)); + $builder = $builder->expiresAt(new DateTimeImmutable('@' . (string)$claimValue)); break; case RegisteredClaims::ID: - $builder->identifiedBy((string)$claimValue); + $builder = $builder->identifiedBy((string)$claimValue); break; case RegisteredClaims::ISSUED_AT: /** @noinspection PhpUnnecessaryStringCastInspection */ - $builder->issuedAt(new DateTimeImmutable('@' . (string)$claimValue)); + $builder = $builder->issuedAt(new DateTimeImmutable('@' . (string)$claimValue)); break; case RegisteredClaims::ISSUER: - $builder->issuedBy((string)$claimValue); + $builder = $builder->issuedBy((string)$claimValue); break; case RegisteredClaims::NOT_BEFORE: /** @noinspection PhpUnnecessaryStringCastInspection */ - $builder->canOnlyBeUsedAfter(new DateTimeImmutable('@' . (string)$claimValue)); + $builder = $builder->canOnlyBeUsedAfter(new DateTimeImmutable('@' . (string)$claimValue)); break; case RegisteredClaims::SUBJECT: - $builder->relatedTo((string)$claimValue); + $builder = $builder->relatedTo((string)$claimValue); break; default: if ($addClaimsFromScopes || array_key_exists($claimName, $additionalClaims)) { - $builder->withClaim($claimName, $claimValue); + $builder = $builder->withClaim($claimName, $claimValue); } } } diff --git a/src/Services/LogoutTokenBuilder.php b/src/Services/LogoutTokenBuilder.php index 23c9746a..4e06f846 100644 --- a/src/Services/LogoutTokenBuilder.php +++ b/src/Services/LogoutTokenBuilder.php @@ -30,7 +30,7 @@ public function forRelyingPartyAssociation(RelyingPartyAssociationInterface $rel ; if ($relyingPartyAssociation->getSessionId() !== null) { - $logoutTokenBuilder->withClaim('sid', $relyingPartyAssociation->getSessionId()); + $logoutTokenBuilder = $logoutTokenBuilder->withClaim('sid', $relyingPartyAssociation->getSessionId()); } return $this->jsonWebTokenBuilderService->getSignedJwtTokenFromBuilder($logoutTokenBuilder)->toString();