Fixed Origin mismatch for passkeys
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m9s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m9s
This commit is contained in:
@@ -3,7 +3,7 @@ import { verifyAuthenticationResponse } from "@simplewebauthn/server";
|
||||
import { db } from "../../../../../db";
|
||||
import { users, passkeys, passkeyChallenges } from "../../../../../db/schema";
|
||||
import { eq, and, gt } from "drizzle-orm";
|
||||
import { setAuthCookie } from "../../../../../lib/auth";
|
||||
import { setAuthCookie, getOrigin } from "../../../../../lib/auth";
|
||||
|
||||
export const POST: APIRoute = async ({ request, cookies }) => {
|
||||
const body = await request.json();
|
||||
@@ -50,11 +50,12 @@ export const POST: APIRoute = async ({ request, cookies }) => {
|
||||
|
||||
let verification;
|
||||
try {
|
||||
const { origin, hostname } = getOrigin();
|
||||
verification = await verifyAuthenticationResponse({
|
||||
response: body,
|
||||
expectedChallenge: challenge as string,
|
||||
expectedOrigin: new URL(request.url).origin,
|
||||
expectedRPID: new URL(request.url).hostname,
|
||||
expectedOrigin: origin,
|
||||
expectedRPID: hostname,
|
||||
credential: {
|
||||
id: passkey.id,
|
||||
publicKey: new Uint8Array(Buffer.from(passkey.publicKey, "base64")),
|
||||
|
||||
Reference in New Issue
Block a user