public function OpenIDConnect::extractSub in OpenID Connect / OAuth client 8
Get the 'sub' property from the user data and/or user claims.
The 'sub' (Subject Identifier) is a unique ID for the external provider to identify the user.
Parameters
array|null $user_data: The user data from OpenIDConnectClientInterface::decodeIdToken().
array|null $userinfo: The user claims from OpenIDConnectClientInterface::retrieveUserInfo().
Return value
string|false The sub, or FALSE if there was an error.
1 call to OpenIDConnect::extractSub()
- OpenIDConnect::buildContext in src/
OpenIDConnect.php - Fill the context array.
File
- src/
OpenIDConnect.php, line 204
Class
- OpenIDConnect
- Main service of the OpenID Connect module.
Namespace
Drupal\openid_connectCode
public function extractSub($user_data, $userinfo) {
if (isset($user_data) && isset($user_data['sub'])) {
// If we have sub in both $user_data and $userinfo, return FALSE if they
// differ. Otherwise return the one in $user_data.
return !isset($userinfo['sub']) || $user_data['sub'] == $userinfo['sub'] ? $user_data['sub'] : FALSE;
}
else {
// No sub in $user_data, return from $userinfo if it exists.
return isset($userinfo['sub']) ? $userinfo['sub'] : FALSE;
}
}