Refine WebAuthn configuration and enhance debug logging for origin verification

Update the WebAuthn configuration to ensure HTTPS origins do not include ports, improving compliance with standards. Add detailed debug logging in the passkey registration process to verify the actual origin from the client response, aiding in troubleshooting and enhancing the clarity of the registration flow.
This commit is contained in:
Torsten Schulz (local)
2026-01-07 21:54:02 +01:00
parent c9c01a4db1
commit ea233d7211
2 changed files with 50 additions and 4 deletions

View File

@@ -55,10 +55,26 @@ export default defineEventHandler(async (event) => {
}
const { origin, rpId, requireUV } = getWebAuthnConfig()
// Debug: Prüfe die tatsächliche Origin aus der Response
const clientData = response?.response?.clientDataJSON
let actualOrigin = null
if (clientData) {
try {
const decoded = Buffer.from(clientData, 'base64').toString('utf-8')
const parsed = JSON.parse(decoded)
actualOrigin = parsed.origin
} catch (e) {
console.warn('[DEBUG] Could not parse clientDataJSON:', e)
}
}
console.log('[DEBUG] WebAuthn config for verification', {
origin,
expectedOrigin: origin,
actualOriginFromResponse: actualOrigin,
rpId,
requireUV
requireUV,
originMatch: origin === actualOrigin
})
console.log('[DEBUG] Verifying registration response...')