public function OpenIDConnectClaims::getScopes in OpenID Connect / OAuth client 8
Same name and namespace in other branches
- 2.x 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 120
Class
- OpenIDConnectClaims
- The OpenID Connect claims service.
Namespace
Drupal\openid_connectCode
public function getScopes(OpenIDConnectClientInterface $client = NULL) {
$claims = $this->configFactory
->getEditable('openid_connect.settings')
->get('userinfo_mappings');
// If a client was provided, get the scopes from it.
$scopes = !empty($client) ? $client
->getClientScopes() : $this->defaultScopes;
$claims_info = $this
->getClaims();
foreach ($claims as $claim) {
if (isset($claims_info[$claim]) && !isset($scopes[$claims_info[$claim]['scope']]) && $claim != 'email') {
$scopes[$claims_info[$claim]['scope']] = $claims_info[$claim]['scope'];
}
}
return implode(' ', $scopes);
}