From a79a01437ac1eb856efb6213a34a405411bcbfdf Mon Sep 17 00:00:00 2001 From: s871077 Date: Tue, 22 Sep 2026 10:39:17 +0800 Subject: [PATCH] fix SSO --- .claude/settings.local.json | 4 +++- helm/templates/server-ingress.yaml | 3 +++ src/auth.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index c146b54..0affde8 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -32,7 +32,9 @@ "Bash(/tmp/windows-amd64/helm.exe template:*)", "Bash(echo \"exit=$?\")", "Read(//tmp/**)", - "Bash(tail:*)" + "Bash(tail:*)", + "Bash(mkdir:*)", + "Bash(python3:*)" ] } } diff --git a/helm/templates/server-ingress.yaml b/helm/templates/server-ingress.yaml index a28b15e..4908f73 100644 --- a/helm/templates/server-ingress.yaml +++ b/helm/templates/server-ingress.yaml @@ -7,6 +7,9 @@ metadata: {{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") | nindent 4 }} annotations: nginx.ingress.kubernetes.io/proxy-body-size: "10m" + # Headroom for large request headers (chunked Auth.js session cookies). + nginx.ingress.kubernetes.io/proxy-buffer-size: "16k" + nginx.ingress.kubernetes.io/proxy-buffers-number: "4" cert-manager.io/cluster-issuer: sectigo-acme spec: ingressClassName: {{ .Values.ingress.className }} diff --git a/src/auth.ts b/src/auth.ts index 3a087c6..01d1c25 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -20,6 +20,18 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, // Tenant-specific issuer restricts sign-in to our organization only. issuer: process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER, + // The provider's default profile() pulls the Graph photo and inlines it as a + // base64 data-URI into user.image -> the `picture` JWT claim. Since sessions + // are JWTs, that becomes a multi-KB chunked session cookie whose combined + // Cookie header overflows nginx's proxy buffer -> 502 before the request ever + // reaches this app. We never render an avatar, so keep the token lean. + authorization: { params: { scope: "openid profile email" } }, + profile: (profile) => ({ + id: profile.sub, + name: profile.name, + email: profile.email, + image: null, + }), }), Credentials({ name: "Local account",