Skip to content

Commit

Permalink
Merge pull request #23 from sgomez/change-builder
Browse files Browse the repository at this point in the history
Moved JWT builder in IdTokenResponse to protected method
  • Loading branch information
steverhoades committed Nov 12, 2018
2 parents bad0523 + 68ce205 commit aa994a8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/IdTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public function __construct(
$this->claimExtractor = $claimExtractor;
}

protected function getBuilder(AccessTokenEntityInterface $accessToken, UserEntityInterface $userEntity)
{
// Add required id_token claims
$builder = (new Builder())
->setAudience($accessToken->getClient()->getIdentifier())
->setIssuer('https://' . $_SERVER['HTTP_HOST'])
->setIssuedAt(time())
->setExpiration($accessToken->getExpiryDateTime()->getTimestamp())
->setSubject($userEntity->getIdentifier());

return $builder;
}

/**
* @param AccessTokenEntityInterface $accessToken
* @return array
Expand All @@ -55,12 +68,7 @@ protected function getExtraParams(AccessTokenEntityInterface $accessToken)
}

// Add required id_token claims
$builder = (new Builder())
->setAudience($accessToken->getClient()->getIdentifier())
->setIssuer('https://' . $_SERVER['HTTP_HOST'])
->setIssuedAt(time())
->setExpiration($accessToken->getExpiryDateTime()->getTimestamp())
->setSubject($userEntity->getIdentifier());
$builder = $this->getBuilder($accessToken, $userEntity);

// Need a claim factory here to reduce the number of claims by provided scope.
$claims = $this->claimExtractor->extract($accessToken->getScopes(), $userEntity->getClaims());
Expand Down

0 comments on commit aa994a8

Please sign in to comment.