fix(auth): keep subsystem oauth working without sso
This commit is contained in:
@@ -112,7 +112,15 @@ export const subsystemApi = {
|
|||||||
const data = await response.json().catch(() => ({}))
|
const data = await response.json().catch(() => ({}))
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
removeToken()
|
removeToken()
|
||||||
redirectToSSO(openApp)
|
const configResponse = await fetch('/auth/api/v1/config', {
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
}).catch(() => null)
|
||||||
|
const config = await configResponse?.json().catch(() => ({}))
|
||||||
|
if (config?.sso_enabled === false) {
|
||||||
|
window.location.assign(`/login?redirect=${encodeURIComponent(`/subsystem?open_app=${openApp}`)}`)
|
||||||
|
} else {
|
||||||
|
redirectToSSO(openApp)
|
||||||
|
}
|
||||||
throw new Error('unauthorized')
|
throw new Error('unauthorized')
|
||||||
}
|
}
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ const handleLocalLogin = async () => {
|
|||||||
try {
|
try {
|
||||||
await login(value, '')
|
await login(value, '')
|
||||||
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : '/'
|
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : '/'
|
||||||
|
if (redirect.startsWith('/auth/')) {
|
||||||
|
window.location.assign(redirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
router.replace(redirect)
|
router.replace(redirect)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ func (h *OAuthHandler) Authorize(c *gin.Context) {
|
|||||||
user, ok := h.sessionUser(c)
|
user, ok := h.sessionUser(c)
|
||||||
if !ok {
|
if !ok {
|
||||||
loginURL := "/auth/api/v1/login/internal-sso?relay_state=" + url.QueryEscape(c.Request.URL.RequestURI())
|
loginURL := "/auth/api/v1/login/internal-sso?relay_state=" + url.QueryEscape(c.Request.URL.RequestURI())
|
||||||
|
if !h.cfg.SSOEnabled {
|
||||||
|
loginURL = "/login?redirect=" + url.QueryEscape(c.Request.URL.RequestURI())
|
||||||
|
}
|
||||||
c.Redirect(http.StatusFound, loginURL)
|
c.Redirect(http.StatusFound, loginURL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user