fix(auth): handle saml logout and xml encryption padding

This commit is contained in:
mac
2026-07-17 09:42:12 +08:00
parent 157f0c65cb
commit b151356045
7 changed files with 112 additions and 12 deletions
+13 -2
View File
@@ -24,6 +24,10 @@ export interface AuthConfig {
sso_enabled: boolean
}
export interface LogoutResponse {
logout_url?: string
}
export const authApi = {
async getConfig(): Promise<ApiResponse<AuthConfig>> {
const response = await fetch('/auth/api/v1/config', {
@@ -64,7 +68,7 @@ export const authApi = {
}
},
async logout(): Promise<ApiResponse<null>> {
async logout(): Promise<ApiResponse<LogoutResponse>> {
const token = getToken()
const response = await fetch('/auth/api/v1/logout', {
method: 'POST',
@@ -78,7 +82,14 @@ export const authApi = {
const data = await response.json().catch(() => ({}))
throw new Error(data.error || `HTTP ${response.status}`)
}
return { code: 0, message: 'success', data: null }
const data = await response.json().catch(() => ({}))
return {
code: 0,
message: 'success',
data: {
logout_url: data.logout_url || '',
},
}
},
async getUserInfo(): Promise<ApiResponse<UserInfo>> {
+4 -2
View File
@@ -13,11 +13,13 @@ export function useAuth() {
}
const logout = async () => {
let logoutUrl = ''
try {
await authApi.logout()
const response = await authApi.logout()
logoutUrl = response.data.logout_url || ''
} finally {
authStore.clearAuth()
window.location.assign('/login?logged_out=1')
window.location.assign(logoutUrl || '/login?logged_out=1')
}
}