From b1c47673ae091bc1a85a04434f2929ba5b8fa8bf Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sun, 22 Oct 2023 14:00:00 +0200 Subject: [PATCH] feat: add login x509 info page (#52) Co-authored-by: Anthony Lukin --- README.md | 1 + html/login/login-x509-info.html | 65 +++++++++++++++++++ .../org/keywind/theme/LoginDataModel.java | 13 ++++ theme/keywind/login/login-x509-info.ftl | 40 ++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 html/login/login-x509-info.html create mode 100644 theme/keywind/login/login-x509-info.ftl diff --git a/README.md b/README.md index 663a0bea4..03f842c16 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Keywind is a component-based Keycloak Login Theme built with [Tailwind CSS](http - Login Update Password - Login Update Profile - Login Username +- Login X.509 Info - Logout Confirm - Register - Select Authenticator diff --git a/html/login/login-x509-info.html b/html/login/login-x509-info.html new file mode 100644 index 000000000..c598e690f --- /dev/null +++ b/html/login/login-x509-info.html @@ -0,0 +1,65 @@ + + + Sign in to + + + + + + + +
+
+
+
+ Keywind +
+

Sign In

+
+
+ +
+
+ X509 client certificate: +
+
+ CN=User, C=US, O=Keywind +
+
+
+ You will be logged in as: Username +
+
+
+ +
+
+
+ +
+
+
+
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/src/test/java/org/keywind/theme/LoginDataModel.java b/src/test/java/org/keywind/theme/LoginDataModel.java index 1641d5ded..be3e33383 100644 --- a/src/test/java/org/keywind/theme/LoginDataModel.java +++ b/src/test/java/org/keywind/theme/LoginDataModel.java @@ -25,6 +25,7 @@ public static Map createDataModel() { dataModel.put("url", createUrlModel()); dataModel.put("user", createUserModel()); dataModel.put("username", "Username"); + dataModel.put("x509", createX509Model()); dataModel.putAll(createWebAuthnModel()); return dataModel; @@ -249,4 +250,16 @@ private static Map createWebAuthnModel() { return webAuthn; } + + private static Map createX509Model() { + Map formData = new HashMap<>(); + formData.put("isUserEnabled", "true"); + formData.put("subjectDN", "CN=User, C=US, O=Keywind"); + formData.put("username", "Username"); + + Map x509 = new HashMap<>(); + x509.put("formData", formData); + + return x509; + } } diff --git a/theme/keywind/login/login-x509-info.ftl b/theme/keywind/login/login-x509-info.ftl new file mode 100644 index 000000000..70d8432c8 --- /dev/null +++ b/theme/keywind/login/login-x509-info.ftl @@ -0,0 +1,40 @@ +<#import "template.ftl" as layout> +<#import "components/atoms/button.ftl" as button> +<#import "components/atoms/button-group.ftl" as buttonGroup> +<#import "components/atoms/form.ftl" as form> +<#import "components/atoms/link.ftl" as link> + +<@layout.registrationLayout; section> + <#if section = "header"> + ${msg("doLogIn")} + <#elseif section = "form"> +
+
${msg("clientCertificate")}
+
+ <#if x509.formData.subjectDN??> + ${(x509.formData.subjectDN!"")} + <#else> + ${msg("noCertificate")} + +
+
+ <#if x509.formData.isUserEnabled??> +
+ ${msg("doX509Login")} + ${(x509.formData.username!'')} +
+ + <@form.kw action=url.loginAction method="post"> + <@buttonGroup.kw> + <@button.kw color="primary" name="login" type="submit"> + ${msg("doContinue")} + + <#if x509.formData.isUserEnabled??> + <@button.kw color="secondary" name="cancel" type="submit"> + ${msg("doIgnore")} + + + + + +