From aa44104095af2fc6ec0681c4fe316935a91477e3 Mon Sep 17 00:00:00 2001 From: aiyimickey <39365912+aiyimickey@users.noreply.github.com> Date: Fri, 3 Jul 2026 12:12:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20OA=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E4=BF=AE=E5=A4=8D=20+=20SSO?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=B4=A6=E5=8F=B7=E6=8C=89=E9=92=AE=20+=20?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=85=8D=E7=BD=AE=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - logout route 使用 request.url.origin 动态获取 base URL - 登录页添加「使用其他账号登录」按钮 - 新增 config/.env.prod 生产环境配置模板 --- config/.env.prod | 13 +++++++++++++ src/app/api/auth/logout/route.ts | 6 ++++-- src/app/login/page.tsx | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 config/.env.prod diff --git a/config/.env.prod b/config/.env.prod new file mode 100644 index 0000000..309e841 --- /dev/null +++ b/config/.env.prod @@ -0,0 +1,13 @@ +# OA 生产环境配置(模板) +# 真实密钥由首次部署时生成,后续部署不覆盖 +LDAP_URL=ldap://lldap:3890 +LDAP_BASE_DN=dc=tlyq,dc=ai +LDAP_ADMIN_DN=uid=admin,ou=people,dc=tlyq,dc=ai +JWT_SECRET=__JWT_SECRET__ +COOKIE_DOMAIN=.tlyq.ai +NODE_ENV=production +NODE_TLS_REJECT_UNAUTHORIZED=0 +AUTHELIA_URL=https://sso.tlyq.ai +OIDC_CLIENT_ID=oa-oidc +OIDC_CLIENT_SECRET=__OIDC_CLIENT_SECRET__ +OIDC_REDIRECT_URI=https://oa.tlyq.ai/api/auth/callback \ No newline at end of file diff --git a/src/app/api/auth/logout/route.ts b/src/app/api/auth/logout/route.ts index 8a73281..17195fe 100644 --- a/src/app/api/auth/logout/route.ts +++ b/src/app/api/auth/logout/route.ts @@ -1,7 +1,7 @@ import { NextResponse } from 'next/server' import { cookies } from 'next/headers' -export async function POST() { +export async function POST(request: Request) { const cookieStore = await cookies() const domain = process.env.COOKIE_DOMAIN || '' @@ -12,5 +12,7 @@ export async function POST() { // Authelia 4.38 不支持 end_session_endpoint,直接跳转登录页 // Authelia session 会在 cookie 过期后自动清除 - return NextResponse.redirect(new URL('/login', process.env.NEXT_PUBLIC_URL || 'http://127.0.0.1:6179')) + // 从请求 URL 动态获取 base URL,避免硬编码 localhost + const { origin } = new URL(request.url) + return NextResponse.redirect(new URL('/login', origin)) } diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index d3a1db0..e0d1cbf 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -52,6 +52,11 @@ function LoginPageContent() { 统一认证登录

通过 SSO 统一身份认证

+

+ +