Skip to content

[Bug] Misleading Error Message After Feishu/DingTalk Authentication Callback #13843

Description

@jianqiangcui996-arch

Contact Information

No response

1Panel Version

  • 1Panel AI 网关 v1.1.0(BUILD_TIME 2026-09-14T10:46, GIT_COMMIT 0d1e2f5) - 部署方式:1Panel 应用商店安装(Docker),前置 Cloudflare Tunnel 提供 HTTPS 公网域名

Problem Description

配置飞书企业登录,测试连接 显示「平台应用凭据验证成功」,但真实登录流程走完后
浏览器落在 /unavailable,前端提示:

企业身份验证失败,请检查账号信息后重试
msg="enterprise authentication failed" endpoint=/api/v1/auth/enterprise/complete operation=complete provider="" status=401 error_class=enterprise_auth_expired stage=completion reason=browser_cookie_missing err="completion: **browser_cookie_missing"

已排除的配置问题

  • 飞书应用:已启用 / 正式应用 / 当前修改均已发布
  • 重定向 URL 与网关 redirectUri 完全一致:https://<域名>/auth/enterprise/callback
  • 网关保存的 clientId / tenantId / redirectUri 三者互相一致,/start 返回的 authorizationUrl 正确
  • 网关容器健康、Tunnel 链路正常(/api/v1/auth/enterprise/providers 正常返回)

实测的 Set-Cookie

POST /api/v1/auth/enterprise/feishu/start → 200 ai_gateway_enterprise=…; Path=/api/v1/auth/enterprise/; Max-Age=300; HttpOnly; SameSite=Lax GET /api/v1/auth/csrf → 204 ai_gateway_csrf=…; Path=/; SameSite=Strict

Steps to Reproduce

我认为需要改的两点

  1. Max-Age=300 对第三方登录过短。 飞书/钉钉登录常需要切到手机扫码,5 分钟内完不成就会失败,
    而失败表现是"cookie 不存在",与"配置错误"无法区分。建议延长到 10 分钟以上,
    或允许在回调页一键"重新发起授权"(复用已填参数)。

  2. 错误提示误导。 browser_cookie_missing / enterprise_auth_expired 被前端统一渲染成
    "请检查账号信息后重试",会把用户引向反复核对 clientId / secret / 回调地址,
    而真实原因是超时。建议区分「state 过期」与「凭据错误」两种文案,
    并在过期时直接给出"重新登录"按钮。

附带疑问(未确认,供参考)

ai_gateway_csrf 使用了 SameSite=Strict。它是否会在"从 IdP 跨站跳回后,
回调页发起的同源 POST"场景下不发送,我没有验证清楚,请维护者确认是否也需要改为 Lax。

复现步骤

  1. 部署 ai-gateway,前置 HTTPS 反代/隧道
  2. 系统设置 → 企业认证 → 飞书:填 clientId / tenantId / secret / 回调地址,启用并保存
  3. 点「测试连接」→ 提示成功
  4. 退出登录 → 登录页点「飞书」→ 完成授权
  5. 若授权耗时超过 5 分钟,稳定复现上述失败

The expected correct result

No response

Related log output

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions