function openid_connect_extract_sub in OpenID Connect / OAuth client 7
Same name and namespace in other branches
- 8 openid_connect.module \openid_connect_extract_sub()
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 $user_data: The user data as returned from OpenIDConnectClientInterface::decodeIdToken().
array $userinfo: The user claims as returned from OpenIDConnectClientInterface::retrieveUserInfo().
Return value
string|false The sub, or FALSE if there was an error.
2 calls to openid_connect_extract_sub()
- openid_connect_complete_authorization in ./
openid_connect.module - Complete the authorization after tokens have been retrieved.
- openid_connect_connect_current_user in ./
openid_connect.module - Connect the current user's account to an external provider.
File
- ./
openid_connect.module, line 764 - A pluggable client implementation for the OpenID Connect protocol.
Code
function openid_connect_extract_sub($user_data, $userinfo) {
if (!isset($user_data['sub']) && !isset($userinfo['sub'])) {
return FALSE;
}
elseif (!isset($user_data['sub'])) {
return $userinfo['sub'];
}
elseif (isset($userinfo['sub']) && $user_data['sub'] != $userinfo['sub']) {
return FALSE;
}
else {
return $user_data['sub'];
}
}