public function OpenIDConnectClaims::getScopes in OpenID Connect / OAuth client 2.x
Same name and namespace in other branches
- 8 src/OpenIDConnectClaims.php \Drupal\openid_connect\OpenIDConnectClaims::getScopes()
Returns scopes that have to be requested based on the configured claims.
Parameters
\Drupal\openid_connect\Plugin\OpenIDConnectClientInterface|null $client: An optional client. If one is provided, it will be asked for scopes.
Return value
string Space delimited case sensitive list of ASCII scope values.
See also
http://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims
File
- src/
OpenIDConnectClaims.php, line 116
Class
- OpenIDConnectClaims
- The OpenID Connect claims service.
Namespace
Drupal\openid_connectCode
public function getScopes(OpenIDConnectClientInterface $client = NULL) : string {
// If a client was provided, get the scopes from it.
$scopes = !empty($client) ? $client
->getClientScopes() : $this->defaultScopes;
$claims_info = $this
->getClaims();
$claims = $this->configFactory
->getEditable('openid_connect.settings')
->get('userinfo_mappings');
foreach ($claims as $claim) {
if (isset($claims_info[$claim]) && !in_array($claims_info[$claim]['scope'], $scopes)) {
$scopes[] = $claims_info[$claim]['scope'];
}
}
return implode(' ', $scopes);
}