From 31337cb7b94f051cc567146a91149338db297e68 Mon Sep 17 00:00:00 2001 From: Guillaume Potier Date: Thu, 15 Sep 2016 18:04:22 +0200 Subject: [PATCH 1/2] Azurev2 | Fix getUserInformation and paths --- OAuth/ResourceOwner/AzureV2ResourceOwner.php | 49 +++----------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/OAuth/ResourceOwner/AzureV2ResourceOwner.php b/OAuth/ResourceOwner/AzureV2ResourceOwner.php index 1b40a57b6..86f80412d 100644 --- a/OAuth/ResourceOwner/AzureV2ResourceOwner.php +++ b/OAuth/ResourceOwner/AzureV2ResourceOwner.php @@ -29,11 +29,11 @@ class AzureV2ResourceOwner extends GenericOAuth2ResourceOwner * {@inheritDoc} */ protected $paths = array( - 'identifier' => 'sub', - 'nickname' => 'preferred_username', - 'realname' => 'name', - 'email' => 'email', - 'profilepicture' => null, + 'identifier' => 'id', + 'email' => 'mail', + 'realname' => 'displayName', + 'firstName' => 'givenName', + 'lastName' => 'surname' ); /** @@ -79,43 +79,6 @@ public function refreshAccessToken($refreshToken, array $extraParameters = array return parent::refreshAccessToken($refreshToken, $extraParameters); } - /** - * {@inheritDoc} - */ - public function getUserInformation(array $accessToken, array $extraParameters = array()) - { - // from http://stackoverflow.com/a/28748285/624544 - list(, $jwt, ) = explode('.', $accessToken['id_token'], 3); - - // if the token was urlencoded, do some fixes to ensure that it is valid base64 encoded - $jwt = str_replace('-', '+', $jwt); - $jwt = str_replace('_', '/', $jwt); - - // complete token if needed - switch (strlen($jwt) % 4) { - case 0: - break; - - case 2: - $jwt .= '='; - - case 3: - $jwt .= '='; - break; - - default: - throw new \InvalidArgumentException('Invalid base64 format sent back'); - } - - $response = $this->getUserResponse(); - $response->setResponse(base64_decode($jwt)); - - $response->setResourceOwner($this); - $response->setOAuthToken(new OAuthToken($accessToken)); - - return $response; - } - /** * {@inheritDoc} */ @@ -126,7 +89,7 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setRequired(array('scope')); $resolver->setDefaults(array( - 'infos_url' => '', + 'infos_url' => 'https://graph.microsoft.com/v1.0/me', 'authorization_url' => 'https://login.microsoftonline.com/%s/oauth2/%s/authorize', 'access_token_url' => 'https://login.microsoftonline.com/%s/oauth2/%s/token', 'application' => 'common', From 688caf904805fc2256c28f4df396a11dbf1dfbf7 Mon Sep 17 00:00:00 2001 From: Guillaume Potier Date: Thu, 15 Sep 2016 18:45:48 +0200 Subject: [PATCH 2/2] Azure | Add nickname path --- OAuth/ResourceOwner/AzureV2ResourceOwner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/OAuth/ResourceOwner/AzureV2ResourceOwner.php b/OAuth/ResourceOwner/AzureV2ResourceOwner.php index 86f80412d..acfb1f74e 100644 --- a/OAuth/ResourceOwner/AzureV2ResourceOwner.php +++ b/OAuth/ResourceOwner/AzureV2ResourceOwner.php @@ -31,6 +31,7 @@ class AzureV2ResourceOwner extends GenericOAuth2ResourceOwner protected $paths = array( 'identifier' => 'id', 'email' => 'mail', + 'nickname' => 'mail', 'realname' => 'displayName', 'firstName' => 'givenName', 'lastName' => 'surname'