Skip to content

Commit

Permalink
Merge pull request #29 from fpicalausa/update-token-builder
Browse files Browse the repository at this point in the history
refactor: move away from deprecated interfaces
  • Loading branch information
steverhoades committed Dec 5, 2020
2 parents eb1a5ee + 830a26d commit b38b082
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
}
],
"require": {
"league/oauth2-server": "^5.1|^6.0|^7.0|^8.0"
"league/oauth2-server": "^5.1|^6.0|^7.0|^8.0",
"lcobucci/jwt": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
Expand Down
15 changes: 7 additions & 8 deletions src/IdTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ protected function getBuilder(AccessTokenEntityInterface $accessToken, UserEntit
{
// 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());
->permittedFor($accessToken->getClient()->getIdentifier())
->issuedBy('https://' . $_SERVER['HTTP_HOST'])
->issuedAt(time())
->expiresAt($accessToken->getExpiryDateTime()->getTimestamp())
->relatedTo($userEntity->getIdentifier());

return $builder;
}
Expand Down Expand Up @@ -74,12 +74,11 @@ protected function getExtraParams(AccessTokenEntityInterface $accessToken)
$claims = $this->claimExtractor->extract($accessToken->getScopes(), $userEntity->getClaims());

foreach ($claims as $claimName => $claimValue) {
$builder->set($claimName, $claimValue);
$builder = $builder->withClaim($claimName, $claimValue);
}

$token = $builder
->sign(new Sha256(), new Key($this->privateKey->getKeyPath(), $this->privateKey->getPassPhrase()))
->getToken();
->getToken(new Sha256(), new Key($this->privateKey->getKeyPath(), $this->privateKey->getPassPhrase()));

return [
'id_token' => (string) $token
Expand Down

0 comments on commit b38b082

Please sign in to comment.