From 72f93fa4f2be50378a22a2a796dc025d21564a26 Mon Sep 17 00:00:00 2001 From: waynemorphic Date: Fri, 19 Jul 2024 13:12:27 +0300 Subject: [PATCH] feat: Add conditional login passkeys --- ...ogin-passkeys-conditional-authenticate.ftl | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 theme/keywind/login/login-passkeys-conditional-authenticate.ftl diff --git a/theme/keywind/login/login-passkeys-conditional-authenticate.ftl b/theme/keywind/login/login-passkeys-conditional-authenticate.ftl new file mode 100644 index 0000000..af82ef2 --- /dev/null +++ b/theme/keywind/login/login-passkeys-conditional-authenticate.ftl @@ -0,0 +1,134 @@ +<#import "template.ftl" as layout> +<#import "components/atoms/form.ftl" as form> +<#import "components/atoms/input.ftl" as input> +<#import "components/atoms/button.ftl" as button> +<#import "components/atoms/button-group.ftl" as buttonGroup> +<#import "components/atoms/link.ftl" as link> + +<@layout.registrationLayout script="dist/webAuthnAuthenticate.js" displayInfo=(realm.registrationAllowed && !registrationDisabled??); section> + <#if section = "title"> + title + <#elseif section = "header"> + ${kcSanitize(msg("passkey-login-title"))?no_esc} + <#elseif section = "form"> +
+
+ + + + + + +
+ +
+ <#if authenticators??> + <@form.kw id="authn_select"> + <#list authenticators.authenticators as authenticator> + <@input.kw type="hidden" name="authn_use_chk" value="${authenticator.credentialId}"/> + + + + <#if shouldDisplayAuthenticators?? && shouldDisplayAuthenticators> +
+ <#if authenticators.authenticators?size gt 1> +

${kcSanitize(msg("passkey-available-authenticators"))?no_esc}

+ + +
+ <#list authenticators.authenticators as authenticator> +
+
+ +
+
+
${kcSanitize(msg(authenticator.label))?no_esc}
+ <#if authenticator.transports?? && authenticator.transports.displayNameProperties?has_content> +
+ <#list authenticator.transports.displayNameProperties as nameProperty> + ${kcSanitize(msg(nameProperty))?no_esc} + <#if nameProperty?has_next> + , + + +
+ +
+ ${kcSanitize(msg('passkey-createdAt-label'))?no_esc} + ${kcSanitize(authenticator.createdAt)?no_esc} +
+
+
+ +
+
+ + + +
+ <#if realm.password> + <@form.kw action="${url.loginAction}" method="post" style="display:none"> + <#if !usernameHidden??> +
+ + <@input.kw + tabindex="1" + id="username" + invalid=messagesPerField.existsError('username') + name="username" + value="${(login.username!'')}" + autocomplete="username webauthn" + type="text" + autofocus=true + /> + <#if messagesPerField.existsError('username')> + ${kcSanitize(messagesPerField.get('username'))?no_esc} + + +
+ + + + +
+ <@buttonGroup.kw> + <@button.kw type="button" @click="doAuthenticate" autofocus="autofocus"> + ${kcSanitize(msg("passkey-doAuthenticate"))} + + <@button.kw type="button" autofocus="autofocus"> + ${kcSanitize(msg("passkey-doAuthenticate"))} + + +
+
+
+
+ + + <#elseif section = "info"> + <#if realm.registrationAllowed && !registrationDisabled??> +
+ + ${msg("noAccount")} + <@link.kw tabindex="6" href="${url.registrationUrl}"> + ${msg("doRegister")} + + +
+ + +