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

Provider Documentation: Micosoft Entra ID #12314

Open
Br4v3St4rr opened this issue Nov 28, 2024 · 5 comments · May be fixed by #12616
Open

Provider Documentation: Micosoft Entra ID #12314

Br4v3St4rr opened this issue Nov 28, 2024 · 5 comments · May be fixed by #12616
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@Br4v3St4rr
Copy link

What is the improvement or update you wish to see?

Hi,

Documentation for the Entra ID provider in the Setup -> Configuration -> NextJS section seems incorrect:

import NextAuth from "next-auth"
import MicrosoftEntraID from "next-auth/providers/microsoft-entra-id"

const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [
    MicrosoftEntraID({
      clientId: process.env.AUTH_MICROSOFT_ENTRA_ID_ID,
      clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET,
      issuer: process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER,
    }),
  ],
})

Should read:

import NextAuth from "next-auth"
import MicrosoftEntraID from "next-auth/providers/microsoft-entra-id"

const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [
    MicrosoftEntraID({
      clientId: process.env.AUTH_MICROSOFT_ENTRA_ID_ID,
      clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET,
      issuer: `https://login.microsoftonline.com/${process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER}/v2.0`,
    }),
  ],
})

Is there any context that might help us understand?

From the below it looks like the provider is expecting a URL in the issuer field.

See https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/microsoft-entra-id.ts Line 108

config.issuer ??= "https://login.microsoftonline.com/common/v2.0"

Does the docs page already exist? Please link to it.

https://authjs.dev/getting-started/providers/microsoft-entra-id

@Br4v3St4rr Br4v3St4rr added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Nov 28, 2024
@graemen16
Copy link

Thanks - I got an error about url format when I changed the Entra definition following update from beta 22 to beta 25. Changing to the url definition resolved the error.

@jenewland1999
Copy link

@Br4v3St4rr Thank you for your posting this. You just saved me many more hours of pain. The docs really need to be updated to specify that the issuer is not just the tenantId but the full url with the tenantId within it (or common if you're using not using a specific directory)

@benhovinga
Copy link
Contributor

The issuer variable needs more documentation. Users coming from Azure Active Directory might assume this is the "Directory (tenant) ID".

Putting the Tenant ID here instead of a URL will give you this error when trying to sign-in

[auth][error] TypeError: Invalid URL

@Br4v3St4rr's solution to change the provider config and assign the URL to issuer there will work. Another solution is to put this URL in your environment variables like below. Same result, just a different way to implement it and doesn't require changing the provider config.

AUTH_MICROSOFT_ENTRA_ID_ID="<Application (client) ID>"
AUTH_MICROSOFT_ENTRA_ID_SECRET="<Client secret (value)>"
AUTH_MICROSOFT_ENTRA_ID_TENANT="<Directory (tenant) ID>"
AUTH_MICROSOFT_ENTRA_ID_ISSUER="https://login.microsoftonline.com/$AUTH_MICROSOFT_ENTRA_ID_TENANT/v2.0"

@rogeriocassares
Copy link
Contributor

THAAAAAAAAAANKSSSS!

Please update de Docs!

@benhovinga
Copy link
Contributor

I'm working on it

@benhovinga benhovinga linked a pull request Feb 6, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants