Draft OpenID Connect support.
This commit is contained in:
@@ -67,6 +67,10 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: 'login',
|
||||
validator: (value) => ['login', 'reauth', 'forbidden'].includes(value)
|
||||
},
|
||||
oidcQueryString: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
})
|
||||
|
||||
@@ -163,7 +167,7 @@ async function authenticateUser() {
|
||||
loading.value = true
|
||||
showMessage('Starting authentication…', 'info')
|
||||
let result
|
||||
try { result = await passkey.authenticate() } catch (error) {
|
||||
try { result = await passkey.authenticate(props.oidcQueryString) } catch (error) {
|
||||
loading.value = false
|
||||
const message = error?.message || 'Passkey authentication cancelled'
|
||||
const cancelled = message === 'Passkey authentication cancelled'
|
||||
@@ -171,6 +175,12 @@ async function authenticateUser() {
|
||||
emit('auth-error', { message, cancelled })
|
||||
return
|
||||
}
|
||||
// OIDC flow: no session cookie, just emit the redirect_url
|
||||
if (result.redirect_url) {
|
||||
loading.value = false
|
||||
emit('authenticated', result)
|
||||
return
|
||||
}
|
||||
try { await setSessionCookie(result) } catch (error) {
|
||||
loading.value = false
|
||||
const message = error?.message || 'Failed to establish session'
|
||||
|
||||
@@ -54,8 +54,13 @@ export async function register(resetToken = null, displayName = null, onstartreg
|
||||
}
|
||||
}
|
||||
|
||||
export async function authenticate() {
|
||||
const ws = await aWebSocket(await makeUrl('/auth/ws/authenticate'))
|
||||
export async function authenticate(queryString = null) {
|
||||
// Build URL, optionally appending raw query string (e.g. for OIDC params)
|
||||
let url = await makeUrl('/auth/ws/authenticate')
|
||||
if (queryString) {
|
||||
url += queryString.startsWith('?') ? queryString : `?${queryString}`
|
||||
}
|
||||
const ws = await aWebSocket(url)
|
||||
try {
|
||||
let res = await ws.receive_json()
|
||||
if (res.status >= 400) throw new Error(res.detail || `Authentication failed: ${res.status}`)
|
||||
|
||||
Reference in New Issue
Block a user