forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix: Fix MS Entra ID and Azure AD authorization (lobehub#4579)
* feat: Add client credentials for Microsoft Entra ID SSO provider Add client ID, client secret, and issuer for the Microsoft Entra ID SSO provider in the next-auth library. * fix env vars * Fix * remove onetime reference
- Loading branch information
1 parent
7204296
commit ced8a08
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { authEnv } from '@/config/auth'; | ||
|
||
function getTenantId() { | ||
return ( | ||
process.env.MICROSOFT_ENTRA_ID_TENANT_ID ?? | ||
process.env.AUTH_AZURE_AD_TENANT_ID ?? | ||
authEnv.AZURE_AD_TENANT_ID | ||
); | ||
} | ||
|
||
function getIssuer() { | ||
const issuer = process.env.MICROSOFT_ENTRA_ID_ISSUER; | ||
if (issuer) { | ||
return issuer; | ||
} | ||
const tenantId = getTenantId(); | ||
if (tenantId) { | ||
// refs: https://github.com/nextauthjs/next-auth/discussions/9154#discussioncomment-10583104 | ||
return `https://login.microsoftonline.com/${tenantId}/v2.0`; | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
|
||
export { getIssuer as getMicrosoftEntraIdIssuer, getTenantId as getMicrosoftEntraIdTenantId }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters