From 1e6093fcf8f8644a759b17def8c3e63f3cb83bb0 Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Mon, 11 Dec 2023 10:03:06 +0100 Subject: [PATCH] feat: add support for passkey nodes --- nodemon.json | 5 ++++- src/routes/login.ts | 2 +- src/routes/registration.ts | 25 +++++++++++++------------ src/routes/settings.ts | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/nodemon.json b/nodemon.json index 9d2904f6..e001b5f8 100644 --- a/nodemon.json +++ b/nodemon.json @@ -7,6 +7,9 @@ "COOKIE_SECRET": "I_AM_VERY_SECRET", "CSRF_COOKIE_SECRET": "I_AM_VERY_SECRET_TOO", "DANGEROUSLY_DISABLE_SECURE_CSRF_COOKIES": "true", - "ORY_SDK_URL": "http://localhost:4000" + "ORY_SDK_URL": "http://localhost:4433", + "KRATOS_PUBLIC_URL": "http://localhost:4433", + "KRATOS_ADMIN_URL": "http://localhost:4434", + "PORT": "4455" } } diff --git a/src/routes/login.ts b/src/routes/login.ts index b45bd8d1..24e49d72 100644 --- a/src/routes/login.ts +++ b/src/routes/login.ts @@ -173,7 +173,7 @@ export const createLoginRoute: RouteCreator = nodes: flow.ui.nodes, webAuthnHandler: filterNodesByGroups({ nodes: flow.ui.nodes, - groups: ["webauthn"], + groups: ["webauthn", "passkey"], attributes: ["button"], withoutDefaultAttributes: true, withoutDefaultGroup: true, diff --git a/src/routes/registration.ts b/src/routes/registration.ts index 37f74710..a422b0a7 100644 --- a/src/routes/registration.ts +++ b/src/routes/registration.ts @@ -79,20 +79,21 @@ export const createRegistrationRoute: RouteCreator = flow.oauth2_login_request.challenge, ) } - res.render("registration", { + const webAuthnHandler = filterNodesByGroups({ nodes: flow.ui.nodes, - webAuthnHandler: filterNodesByGroups({ - nodes: flow.ui.nodes, - groups: ["webauthn"], - attributes: ["button"], - withoutDefaultAttributes: true, - withoutDefaultGroup: true, + groups: ["webauthn", "passkey"], + attributes: ["button"], + withoutDefaultAttributes: true, + withoutDefaultGroup: true, + }) + .filter(({ attributes }) => isUiNodeInputAttributes(attributes)) + .map(({ attributes }) => { + return (attributes as UiNodeInputAttributes).onclick }) - .filter(({ attributes }) => isUiNodeInputAttributes(attributes)) - .map(({ attributes }) => { - return (attributes as UiNodeInputAttributes).onclick - }) - .filter((onClickAction) => !!onClickAction), + .filter((onClickAction) => !!onClickAction) + res.render("registration", { + nodes: flow.ui.nodes, + webAuthnHandler: webAuthnHandler, card: UserAuthCard( { flow, diff --git a/src/routes/settings.ts b/src/routes/settings.ts index aa73b9fb..0f948761 100644 --- a/src/routes/settings.ts +++ b/src/routes/settings.ts @@ -74,7 +74,7 @@ export const createSettingsRoute: RouteCreator = settingsScreen: settingsScreen.Body, webAuthnHandler: filterNodesByGroups({ nodes: flow.ui.nodes, - groups: ["webauthn"], + groups: ["webauthn", "passkey"], attributes: ["button"], withoutDefaultAttributes: true, withoutDefaultGroup: true,