Skip to content

fix(provider): Microsoft Entra ID #12616

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

Merged
merged 18 commits into from
Jun 22, 2025

Conversation

benhovinga
Copy link
Contributor

@benhovinga benhovinga commented Feb 6, 2025

☕️ Reasoning

This PR resolves several issues with the Microsoft Entra ID provider.

Fix Documentation

Inconsistencies between the use of issuer and tenantId. This implementation of the provider doesn't directly use tenantId however it is used within part of the issuer URI string. This PR clarifies how to use the issuer parameter in both the Provider Docs and API Reference.

Also fixed some inconsistencies between frameworks

Fix MicrosoftEntraIDProfile interface

The MicrosoftEntraIDProfile interface was missing a lot of the claims returned from the provider server. This PR adds all id_token claims.

Fix default issuer

If the environment variable AUTH_MICROSOFT_ENTRA_ID_ISSUER is configured but the issuer parameter is not set, the default issuer overwrites the environment variable. This PR checks if the environment variable is configured first before falling back to the default issuer.

Now the provider "can" be used without any configuration, like this.

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

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [MicrosoftEntraID]
});
AUTH_MICROSOFT_ENTRA_ID_ID="<client id>"
AUTH_MICROSOFT_ENTRA_ID_SECRET="<client secret>"
AUTH_MICROSOFT_ENTRA_ID_ISSUER="https://login.microsoftonline.com/<tenant id>/v2.0"

Finish Provider Implementation

Add the provider to the OAuth providers search and the Issues Template providers dropdown.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixes: #12314, #12193, #12195
Corrects: #12612

📌 Resources

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2025 11:30am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2025 11:30am

Copy link

vercel bot commented Feb 6, 2025

@benhovinga is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 380 lines in your changes missing coverage. Please review.

Project coverage is 39.00%. Comparing base (63d90a0) to head (444a9a9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/core/src/providers/microsoft-entra-id.ts 0.00% 380 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12616      +/-   ##
==========================================
- Coverage   39.42%   39.00%   -0.42%     
==========================================
  Files         200      200              
  Lines       31782    32122     +340     
  Branches     1393     1399       +6     
==========================================
  Hits        12529    12529              
- Misses      19253    19593     +340     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benhovinga
Copy link
Contributor Author

Ref: Codecov #12616 (comment)

Is there an example of testing providers? Most of the providers don't have tests. The ones that do have coverage, like Auth0 has 100% coverage, I cannot find where they are tested in the repo.

ndom91
ndom91 previously requested changes Mar 15, 2025
Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 small change, but other wise this looks great. Thanks a lot!

@benhovinga
Copy link
Contributor Author

@ndom91 Could you re-review? I made the changes.

@ThangHuuVu ThangHuuVu merged commit e16b07b into nextauthjs:main Jun 22, 2025
11 of 15 checks passed
@benhovinga benhovinga deleted the microsoft-entra-id branch June 23, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider Documentation: Micosoft Entra ID
4 participants