Skip to content

Commit

Permalink
refactor: extract methods for validating scopes & audience separately
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Dec 10, 2024
1 parent b865097 commit 6fe0830
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Provider/Traits/TokenValidatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function validateScope($token, array $scope)
// check expected scopes are included
$scp = is_array($token->scp) ? array_unique($token->scp) : [];
if (count(array_intersect($scope, $scp)) < count($scope)) {
throw new Exception\ScopeInvalidException('Expected scopes not matched: ' . implode(', ', $scope));
throw new Exception\ScopeInvalidException('Expected scope not matched: ' . implode(', ', $scope));
}
}

Expand All @@ -128,7 +128,7 @@ public function validateAudience($token, array $audience)
// check expected audiences are included
$aud = is_array($token->aud) ? array_unique($token->aud) : [];
if (count(array_intersect($audience, $aud)) < count($audience)) {
throw new Exception\AudienceInvalidException('Expected audiences not matched: ' . implode(', ', $audience));
throw new Exception\AudienceInvalidException('Expected audience not matched: ' . implode(', ', $audience));
}
}
}

0 comments on commit 6fe0830

Please sign in to comment.