You are here

public function OpenIdConnectScopeRepository::finalizeScopes in Simple OAuth (OAuth2) & OpenID Connect 5.x

File

src/OpenIdConnect/OpenIdConnectScopeRepository.php, line 57

Class

OpenIdConnectScopeRepository
OpenID Connect scope repository decorator.

Namespace

Drupal\simple_oauth\OpenIdConnect

Code

public function finalizeScopes(array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = NULL) {
  $finalized_scopes = $this->innerScopeRepository
    ->finalizeScopes($scopes, $grantType, $clientEntity, $userIdentifier);

  // Make sure that the openid scopes are in the user list.
  $openid_scopes = $this
    ->getOpenIdScopes();
  foreach ($scopes as $scope) {
    if (isset($openid_scopes[$scope
      ->getIdentifier()])) {
      $finalized_scopes = $this
        ->addRoleToScopes($finalized_scopes, new OpenIdConnectScopeEntity($scope
        ->getIdentifier(), $openid_scopes[$scope
        ->getIdentifier()]));
    }
  }
  return $finalized_scopes;
}