fix(auth): runtime allowlist return_to с private для LAN SSO
Build and Push Auth Portal Docker Image / build-and-push (push) Successful in 3m15s
Build and Push Auth Portal Docker Image / create-release (push) Skipped

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-18 14:00:05 +07:00
co-authored by Cursor
parent 1cc58977fd
commit 961242506b
5 changed files with 51 additions and 18 deletions
+36
View File
@@ -1,5 +1,41 @@
const TOKEN_KEY = 'authportal_token'
/** Fallback if /api/v1/auth/config unavailable (dev). Includes `private` for LAN SSO. */
export const DEFAULT_RETURN_TO_ALLOWLIST =
'.shnt.top,localhost,private,http://localhost:5173'
let returnToAllowlist: string | null = null
let returnToAllowlistPromise: Promise<string> | null = null
export async function ensureReturnToAllowlist(): Promise<string> {
if (returnToAllowlist) return returnToAllowlist
if (returnToAllowlistPromise) return returnToAllowlistPromise
returnToAllowlistPromise = (async () => {
const fromVite = import.meta.env.VITE_RETURN_TO_ALLOWLIST as
| string
| undefined
try {
const res = await fetch('/api/v1/auth/config')
if (res.ok) {
const data = (await res.json()) as { return_to_allowlist?: string }
if (data.return_to_allowlist) {
returnToAllowlist = data.return_to_allowlist
return returnToAllowlist
}
}
} catch {
/* ignore */
}
returnToAllowlist = fromVite || DEFAULT_RETURN_TO_ALLOWLIST
return returnToAllowlist
})().finally(() => {
returnToAllowlistPromise = null
})
return returnToAllowlistPromise
}
export function getToken(): string | null {
return localStorage.getItem(TOKEN_KEY)
}