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

Signing up with Azure AD does not set the users email #404

Closed
hk-meko opened this issue Jul 11, 2023 · 2 comments
Closed

Signing up with Azure AD does not set the users email #404

hk-meko opened this issue Jul 11, 2023 · 2 comments

Comments

@hk-meko
Copy link

hk-meko commented Jul 11, 2023

When using AzureAD for signup/ signin, the users email is not set in the database.
This part of the azuread config is the falsey part. The payload field containing the email is named "upn", in the config it's email

azuread: {
    grant: {
      oauth: 2,
      scope_delimiter: ' ',
      client_id: process.env.AUTH_PROVIDER_AZUREAD_CLIENT_ID,
      client_secret: process.env.AUTH_PROVIDER_AZUREAD_CLIENT_SECRET,
      authorize_url: `${azureBaseUrl}/[subdomain]/oauth2/authorize`,
      access_url: `${azureBaseUrl}/[subdomain]/oauth2/token`,
      profile_url: `${azureBaseUrl}/[subdomain]/openid/userinfo`,
      subdomain: process.env.AUTH_PROVIDER_AZUREAD_TENANT || 'common',
    },
    profile: ({ jwt }) => {
      const payload = jwt?.id_token?.payload;
      return {
        id: payload.oid,
        displayName: payload.name,
        email: payload.email,
      };
    },
  },

Here is a privatized OAuth response from AzureAD:

{
  "id_token": "...",
  "access_token": "...",
  "refresh_token": "...",
  "jwt": {
    "id_token": {
      "header": {
        "typ": "JWT",
        "alg": "none"
      },
      "payload": {
        "aud": "...",
        "iss": "https://sts.windows.net/.../",
        "iat": 1689073876,
        "nbf": 1689073876,
        "exp": 1689077776,
        "amr": [
          "pwd",
          "mfa"
        ],
        "family_name": "Doe",
        "given_name": "John",
        "ipaddr": "12.345.78.912",
        "name": "John Doe",
        "oid": "...",
        "onprem_sid": "...",
        "rh": "...",
        "sub": "...",
        "tid": "...",
        "unique_name": "email@email.com",
        "upn": "email@email.com",
        "ver": "1.0"
      },
      "signature": ""
    }
  },
  "profile": {
    "error": {}
  }
}

I hope this can be fixed quickly, with the provided information.

@dbarrosop
Copy link
Member

Given you have already identified the root cause and are a bit in a hurry here, would you mind opening a PR fixing it? Thanks!

hk-meko added a commit to hk-meko/hasura-auth that referenced this issue Jul 11, 2023
@dbarrosop
Copy link
Member

Closing as per the following comment: #405 (comment)

@dbarrosop dbarrosop reopened this Jul 12, 2023
@dbarrosop dbarrosop changed the title Signing up with Azure AD does not set the users email documentation: requirements for signing up with Azure AD Jul 12, 2023
@dbarrosop dbarrosop changed the title documentation: requirements for signing up with Azure AD Signing up with Azure AD does not set the users email Jul 12, 2023
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

Successfully merging a pull request may close this issue.

2 participants