Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureADB2C has error in emails mapping #1165

Open
baradhili opened this issue Mar 4, 2024 · 3 comments
Open

AzureADB2C has error in emails mapping #1165

baradhili opened this issue Mar 4, 2024 · 3 comments

Comments

@baradhili
Copy link

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
Copy link
Author

note socialIdpUserId also contains the email

@atymic
Copy link
Member

atymic commented Mar 4, 2024

Can you link to the docs please? PR welcome

@baradhili
Copy link
Author

PR sent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants