fix(auth): validate WebAuthn rp.id against current host

Add ensureValidRpId helper to validate and correct rp.id for WebAuthn
operations, preventing authentication failures when the configured rp.id
doesn't match the current hostname. Also add OAuthProvider type and fix
type casting in LoginPage.
This commit is contained in:
2026-02-24 01:20:41 +10:30
parent e854bf801e
commit 5c2971e38d
5 changed files with 27 additions and 3 deletions
+2 -2
View File
@@ -218,7 +218,7 @@ export default function LoginPage() {
try {
// Step 1: Get login options from server
const options = await api.webauthn.beginLogin(emailToUse) as WebAuthnLoginOptions;
const options = await api.webauthn.beginLogin(emailToUse) as unknown as WebAuthnLoginOptions;
// Step 2: Create assertion using browser WebAuthn API
const assertion = await createLoginAssertion(options);
@@ -286,7 +286,7 @@ export default function LoginPage() {
try {
// Step 1: Get login options from server
const options = await api.webauthn.beginLogin(email) as WebAuthnLoginOptions;
const options = await api.webauthn.beginLogin(email) as unknown as WebAuthnLoginOptions;
// Step 2: Create assertion using browser WebAuthn API
const assertion = await createLoginAssertion(options);