Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style: Added `AUTH_MICROSOFT_ENTRA_ID_BASE_URL` routing (#9293)

Jim Seiwert78a2f9e8749f
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 9a983d7ac36..50b06d19f6c 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,6 +1,7 @@
{
- "image": "mcr.microsoft.com/devcontainers/typescript-node",
"features": {
- "ghcr.io/devcontainer-community/devcontainer-features/bun.sh:1": {}
- }
+ "ghcr.io/devcontainer-community/devcontainer-features/bun.sh:1": {},
+ "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
+ },
+ "image": "mcr.microsoft.com/devcontainers/typescript-node"
}
diff --git a/docs/self-hosting/environment-variables/auth.mdx b/docs/self-hosting/environment-variables/auth.mdx
index f7a3169c502..34c0b1a66a0 100644
--- a/docs/self-hosting/environment-variables/auth.mdx
+++ b/docs/self-hosting/environment-variables/auth.mdx
@@ -205,6 +205,13 @@ LobeChat provides a complete authentication service capability when deployed. Th
### Microsoft Entra ID
+#### `AUTH_MICROSOFT_ENTRA_ID_BASE_URL`
+
+- Type: Required
+- Description: - Description: Base URL for Azure login. Use when authenticating against other Microsoft sovereignty clouds like Azure US Government.
+- Default: `https://login.microsoftonline.com`
+- Example: `https://login.microsoftonline.us`
+
#### `AUTH_AZURE_AD_ID`
- Type: Required
diff --git a/src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts b/src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts
index 3a3c4c72b35..8edd140270d 100644
--- a/src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts
+++ b/src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts
@@ -8,6 +8,10 @@ function getTenantId() {
);
}
+function getClientLoginBaseUrl() {
+ return process.env.AUTH_MICROSOFT_ENTRA_ID_BASE_URL ?? 'https://login.microsoftonline.com';
+}
+
function getIssuer() {
const issuer = process.env.MICROSOFT_ENTRA_ID_ISSUER;
if (issuer) {
@@ -16,7 +20,7 @@ function getIssuer() {
const tenantId = getTenantId();
if (tenantId) {
// refs: https://github.com/nextauthjs/next-auth/discussions/9154#discussioncomment-10583104
- return `https://login.microsoftonline.com/${tenantId}/v2.0`;
+ return `${getClientLoginBaseUrl()}/${tenantId}/v2.0`;
} else {
return undefined;
}