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

fix(provider): Microsoft Entra ID #12616

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

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 Feb 21, 2025 3:20pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Feb 21, 2025 3:20pm

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 381 lines in your changes missing coverage. Please review.

Project coverage is 39.04%. Comparing base (507aadd) to head (1f8bd46).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/core/src/providers/microsoft-entra-id.ts 0.00% 381 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12616      +/-   ##
==========================================
- Coverage   39.41%   39.04%   -0.38%     
==========================================
  Files         198      198              
  Lines       31294    31644     +350     
  Branches     1376     1378       +2     
==========================================
+ Hits        12334    12354      +20     
- Misses      18960    19290     +330     

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

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
2 participants