Skip to content

Commit

Permalink
Automated CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CS Fixer authored and bobvandevijver committed Aug 13, 2024
1 parent 47bc477 commit ee5024b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/Model/OidcTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@
*/
class OidcTokens extends UnvalidatedOidcTokens
{
/**
* @throws OidcException
*/
/** @throws OidcException */
public function __construct(UnvalidatedOidcTokens|stdClass $tokens)
{
// These are the only required parameters per https://tools.ietf.org/html/rfc6749#section-4.2.2
if ($tokens instanceof UnvalidatedOidcTokens) {
if ((null === $tokens->idToken) || (null === $tokens->accessToken)) {
throw new OidcException('Invalid token object.');
}

} else {
if (!isset($tokens->id_token) || !isset($tokens->access_token)) {
throw new OidcException('Invalid token object.');
Expand Down
13 changes: 6 additions & 7 deletions src/Model/UnvalidatedOidcTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ class UnvalidatedOidcTokens
/** @var string[]|null */
private ?array $scope = null;

/**
* @throws OidcException
*/
/** @throws OidcException */
public function __construct(UnvalidatedOidcTokens|stdClass $tokens)
{
if ($tokens instanceof self) {
$this->accessToken = $tokens->accessToken;
$this->idToken = $tokens->idToken;
$this->expiry = DateTimeImmutable::createFromInterface($tokens->expiry);
$this->accessToken = $tokens->accessToken;
$this->idToken = $tokens->idToken;
$this->expiry = DateTimeImmutable::createFromInterface($tokens->expiry);
$this->refreshToken = $tokens->refreshToken;
$this->scope = $tokens->scope;
$this->scope = $tokens->scope;

return;
}

Expand Down
1 change: 0 additions & 1 deletion src/OidcClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Drenso\OidcBundle\Exception\OidcException;
use Drenso\OidcBundle\Model\OidcTokens;
use Drenso\OidcBundle\Model\OidcUserData;
use Drenso\OidcBundle\Model\UnvalidatedOidcTokens;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

Expand Down
4 changes: 2 additions & 2 deletions src/OidcJwtHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function verifyTokens(string $issuer, string $jwksUri, OidcTokens $tokens

public function verifyIdToken(string $issuer, string $jwksUri, OidcTokens $tokens, bool $verifyNonce): void
{
$idToken = $tokens->getTokenByType(OidcTokenType::ID);
$idToken = $tokens->getTokenByType(OidcTokenType::ID);
$accessToken = $tokens->getTokenByType(OidcTokenType::ACCESS);

$additionalIdTokenConstraints = $this->oidcTokenConstraintProvider?->getAdditionalConstraints(OidcTokenType::ID) ?? [];
Expand All @@ -109,7 +109,7 @@ public function verifyIdToken(string $issuer, string $jwksUri, OidcTokens $token

public function verifyAccessToken(string $issuer, string $jwksUri, OidcTokens $tokens, bool $verifyNonce): void
{
$accessToken = $tokens->getTokenByType(OidcTokenType::ACCESS);
$accessToken = $tokens->getTokenByType(OidcTokenType::ACCESS);
$additionalAccessTokenConstraints = $this->oidcTokenConstraintProvider?->getAdditionalConstraints(OidcTokenType::ACCESS) ?? [];
try {
$this->verifyToken($issuer, $jwksUri, OidcTokenType::ACCESS, self::parseToken($accessToken), false, null, ...$additionalAccessTokenConstraints);
Expand Down

0 comments on commit ee5024b

Please sign in to comment.