feat(auth): complete sso subsystem integration

This commit is contained in:
mac
2026-07-16 15:52:56 +08:00
parent f8c389606f
commit eb2621d914
24 changed files with 1977 additions and 111 deletions
+11 -3
View File
@@ -2,7 +2,15 @@ import { setToken } from '@/utils/auth'
const SSO_LOGIN_PATH = '/auth/api/v1/login/internal-sso'
export function relayState(openApp = ''): string {
export function relayState(openApp = '', fallbackPath = ''): string {
if (fallbackPath) {
const target = new URL(fallbackPath, window.location.origin)
if (openApp) {
target.searchParams.set('open_app', openApp)
}
return `${target.pathname}${target.search}${target.hash}` || '/'
}
const url = new URL(window.location.href)
url.searchParams.delete('sso_token')
url.searchParams.delete('open_app')
@@ -12,8 +20,8 @@ export function relayState(openApp = ''): string {
return `${url.pathname}${url.search}${url.hash}` || '/'
}
export function redirectToSSO(openApp = ''): void {
window.location.assign(`${SSO_LOGIN_PATH}?relay_state=${encodeURIComponent(relayState(openApp))}`)
export function redirectToSSO(openApp = '', fallbackPath = ''): void {
window.location.assign(`${SSO_LOGIN_PATH}?relay_state=${encodeURIComponent(relayState(openApp, fallbackPath))}`)
}
export function consumeSSOToken(): string {