Skip to content

Commit

Permalink
Accommodate for new immutable behavior of Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
cicnavi committed May 20, 2024
1 parent 2ce73b0 commit 1a6fe33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/Services/IdTokenBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/LogoutTokenBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1a6fe33

Please sign in to comment.