fix(auth): allow anonymous access to share-link endpoints (#1617)
The global Auth middleware allowlist (noAuthAPI) was missing the share-link routes, so an unauthenticated invitee opening /register?token= hit a 401 on /auth/invitations/lookup and the frontend bounced them to /login instead of showing the register page. Add both share-link endpoints to the allowlist and stop the request interceptor from treating their 401s as a session-expiry redirect. Refs: https://github.com/Tencent/WeKnora/issues/1617
This commit is contained in:
@@ -20,15 +20,23 @@ import (
|
||||
|
||||
// 无需认证的API列表
|
||||
var noAuthAPI = map[string][]string{
|
||||
"/health": {"GET"},
|
||||
"/api/v1/auth/register": {"POST"},
|
||||
"/api/v1/auth/login": {"POST"},
|
||||
"/api/v1/auth/auto-setup": {"POST"},
|
||||
"/api/v1/auth/config": {"GET"},
|
||||
"/api/v1/auth/oidc/config": {"GET"},
|
||||
"/api/v1/auth/oidc/url": {"GET"},
|
||||
"/api/v1/auth/oidc/callback": {"GET"},
|
||||
"/api/v1/auth/refresh": {"POST"},
|
||||
"/health": {"GET"},
|
||||
"/api/v1/auth/register": {"POST"},
|
||||
"/api/v1/auth/login": {"POST"},
|
||||
"/api/v1/auth/auto-setup": {"POST"},
|
||||
// Share-link surfaces accept a plaintext invite token from anonymous
|
||||
// callers (an invitee who hasn't registered yet). They are registered
|
||||
// as public routes in RegisterAuthRoutes and rate-limited by IP, so the
|
||||
// global Auth middleware must let them through — otherwise opening a
|
||||
// share link while logged out 401s and the frontend bounces the user to
|
||||
// /login instead of the register page (issue #1617).
|
||||
"/api/v1/auth/invitations/lookup": {"POST"},
|
||||
"/api/v1/auth/register-by-invite": {"POST"},
|
||||
"/api/v1/auth/config": {"GET"},
|
||||
"/api/v1/auth/oidc/config": {"GET"},
|
||||
"/api/v1/auth/oidc/url": {"GET"},
|
||||
"/api/v1/auth/oidc/callback": {"GET"},
|
||||
"/api/v1/auth/refresh": {"POST"},
|
||||
// IM platforms (Feishu, Slack, etc.) commonly issue a HEAD request
|
||||
// before GET to validate Content-Type / Content-Length when rendering
|
||||
// image previews — both verbs must be allowed for image links to work.
|
||||
|
||||
Reference in New Issue
Block a user