SocialiteProviders / Providers

A Collection of Providers for Laravel Socialite
https://socialiteproviders.com
MIT License
499 stars 438 forks source link

AzureADB2C has error in emails mapping #1165

Open baradhili opened 7 months ago

baradhili commented 7 months ago

currently this is in Provider

protected function mapUserToObject(array $user)
    {
        return(new User())->setRaw($user)->map([
            'id' => $user['sub'],
            'nickname' => $user['name'],
            'name' => $user['name'],
            'email' => $user['emails'][0],
        ]);
    }

However Azure OpenID returns:

[ver] => 1.0
    [iss] => 
    [sub] => 
    [aud] => 
    [exp] => 
    [acr] => b2c_1a_dev_ob_shared_corpaad_basic_signin
    [iat] => 
    [auth_time] => 
    [socialIdpUserId] => 
    [given_name] => 
    [family_name] => 
    [email] => 
    [name] => 
    [authenticationSource] => 
    [idp] => 
    [nbf] => 

code should be

protected function mapUserToObject(array $user)
    {
        return(new User())->setRaw($user)->map([
            'id' => $user['sub'],
            'nickname' => $user['name'],
            'name' => $user['name'],
            'email' => $user['email'],
        ]);
    }

Though I suspect this might also be a MS barf and I wouldn't be surprised if they return different claims depending on the policy type etc.. might need to do some decisions before mapping

baradhili commented 7 months ago

note socialIdpUserId also contains the email

atymic commented 7 months ago

Can you link to the docs please? PR welcome

baradhili commented 7 months ago

PR sent