OIDC: local HTTP server instead of Wails bindings
The Wails runtime isn't reliably loading for IPC calls. Replace the binding-based StartOIDCLogin with a local HTTP server on 127.0.0.1:18901: - /oidc/login?apiUrl=... — opens system browser, waits for token - /oidc/callback — Authentik redirect target, exchanges code - /oidc/config?apiUrl=... — fetches OIDC provider config - SPA detects desktop via ?desktop=1 URL param - SPA calls localhost directly via fetch() instead of Wails IPC
This commit is contained in:
@@ -68,21 +68,25 @@
|
||||
oidcLoggingIn = true
|
||||
setConfig({ apiUrl: apiUrl.trim(), token: '' })
|
||||
|
||||
const wails = (window as any).wails
|
||||
if (wails?.Call?.ByName) {
|
||||
const isDesktop = new URLSearchParams(location.search).has('desktop')
|
||||
|
||||
if (isDesktop) {
|
||||
try {
|
||||
const token = await wails.Call.ByName('StartOIDCLogin', apiUrl.trim())
|
||||
if (token) {
|
||||
setConfig({ apiUrl: apiUrl.trim(), token })
|
||||
initConfig({ apiUrl: apiUrl.trim(), token })
|
||||
const resp = await fetch(`http://127.0.0.1:18901/oidc/login?apiUrl=${encodeURIComponent(apiUrl.trim())}`)
|
||||
const data = await resp.json()
|
||||
if (data.token) {
|
||||
setConfig({ apiUrl: apiUrl.trim(), token: data.token })
|
||||
initConfig({ apiUrl: apiUrl.trim(), token: data.token })
|
||||
oidcLoggingIn = false
|
||||
onConnected()
|
||||
return
|
||||
}
|
||||
error = data.error || 'Login failed'
|
||||
} catch (e: any) {
|
||||
error = e?.message || e || 'OIDC login failed'
|
||||
oidcLoggingIn = false
|
||||
return
|
||||
error = e.message || 'Could not reach OIDC service'
|
||||
}
|
||||
oidcLoggingIn = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user