diff --git a/README.md b/README.md index 72bfc6c..5c73e9d 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ keycloak-modern-login is a Keycloak login theme that's build using Tailwind CSS, ![](docs/login-form.jpg) -![](docs/select-authenticator.jpg) - ![](docs/login-webauthn.jpg) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8397665..0bef6c5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,7 @@ version: "3.3" services: keycloak: - image: quay.io/keycloak/keycloak:latest + image: quay.io/keycloak/keycloak:20.0.3 ports: - "8080:8080" volumes: @@ -12,5 +12,4 @@ services: - KEYCLOAK_ADMIN_PASSWORD=admin command: - start-dev - - --features=recovery-codes - --import-realm diff --git a/docs/select-authenticator.jpg b/docs/select-authenticator.jpg deleted file mode 100644 index 1b6e022..0000000 Binary files a/docs/select-authenticator.jpg and /dev/null differ diff --git a/package.json b/package.json index 490b5de..cf7ae9b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "prod": "webpack --mode=production", "zipjar": "cd dist; zip -r ../dist/theme.jar META-INF theme; cd -", "build": "yarn prod && yarn zipjar", - "format": "prettier --write src/", + "format": "prettier --write .", "lint": "eslint --cache --report-unused-disable-directives --format codeframe --ext js,ts,vue ." }, "devDependencies": { diff --git a/src/functions/utils.ts b/src/functions/utils.ts deleted file mode 100644 index 4a28423..0000000 --- a/src/functions/utils.ts +++ /dev/null @@ -1,22 +0,0 @@ -export function formPost(url: string, data: object) { - const form = document.createElement("form"); - form.method = "post"; - form.action = url; - - for (const key in data) { - if (Object.prototype.hasOwnProperty.call(data, key)) { - if (data[key] === undefined) { - continue; - } - - const hiddenField = document.createElement("input"); - hiddenField.type = "hidden"; - hiddenField.name = key; - hiddenField.value = data[key]; - - form.appendChild(hiddenField); - } - } - document.body.appendChild(form); - form.submit(); -} diff --git a/src/types/context.ts b/src/types/context.ts index 348afbb..1a7c3a8 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -31,19 +31,6 @@ export type WebauthnAuthenticator = { createdAt: string; }; -export type AuthenticationSelection = { - authExecId: string; - authenticationExecution: { - alternative: boolean; - enabled: boolean; - authenticator: - | "auth-otp-form" - | "webauthn-authenticator" - | "auth-recovery-authn-code-form"; - priority: string; - }; -}; - export declare namespace KcContextBase { export type Common = { url: { @@ -340,19 +327,13 @@ export declare namespace KcContextBase { }; export type SAMLPostForm = Common & { - pageId: "saml-post-form.ftl"; + pageId: "saml-post-form.ftl" samlPost: { url: string; SAMLRequest?: string; SAMLResponse?: string; relayState?: string; - }; - }; - - export type SelectAuthenticator = Common & { - auth: { - authenticationSelections: Array; - }; + } }; } diff --git a/src/types/samlPostData.ts b/src/types/samlPostData.ts index c945655..edc3d0a 100644 --- a/src/types/samlPostData.ts +++ b/src/types/samlPostData.ts @@ -1,5 +1,5 @@ export type SAMLPostData = { - SAMLRequest?: string; - SAMLResponse?: string; - RelayState?: string; -}; + SAMLRequest?: string, + SAMLResponse?: string, + RelayState?: string, +} \ No newline at end of file diff --git a/src/views/saml-post-form/index.vue b/src/views/saml-post-form/index.vue index ead43f7..c260cae 100644 --- a/src/views/saml-post-form/index.vue +++ b/src/views/saml-post-form/index.vue @@ -2,14 +2,7 @@
- +

Redirecting...

@@ -19,8 +12,7 @@ import { defineComponent } from "vue"; import Layout from "~/components/Layout.vue"; import type { KcContextBase } from "~/types/context"; -import type { SAMLPostData } from "~/types/samlPostData"; -import { formPost } from "~/functions/utils"; +import type { SAMLPostData } from "~/types/samlPostData" export default defineComponent({ name: "SamlPostForm", @@ -38,7 +30,31 @@ export default defineComponent({ SAMLResponse: this.context.samlPost.SAMLResponse, RelayState: this.context.samlPost.relayState, }; - formPost(this.context.samlPost.url, postData); + this.formPost(this.context.samlPost.url, postData); + }, + methods: { + formPost(url: string, data: object) { + const form = document.createElement("form"); + form.method = "post"; + form.action = url; + + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + if (data[key] === undefined) { + continue; + } + + const hiddenField = document.createElement("input"); + hiddenField.type = "hidden"; + hiddenField.name = key; + hiddenField.value = data[key]; + + form.appendChild(hiddenField); + } + } + document.body.appendChild(form); + form.submit(); + }, }, }); diff --git a/src/views/select-authenticator/index.ftl b/src/views/select-authenticator/index.ftl deleted file mode 100644 index c45b1f6..0000000 --- a/src/views/select-authenticator/index.ftl +++ /dev/null @@ -1,6 +0,0 @@ -<#import "baselayout.ftl" as layout> -<@layout.baseLayout pageId="select-authenticator.ftl" ; section> - <#if section = "scripts"> - - - diff --git a/src/views/select-authenticator/index.ts b/src/views/select-authenticator/index.ts deleted file mode 100644 index 9344ee4..0000000 --- a/src/views/select-authenticator/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { createApp } from "vue"; -import index from "./index.vue"; - -if ((window as any).kcContext) { - const app = createApp(index); - app.mount("#app"); -} diff --git a/src/views/select-authenticator/index.vue b/src/views/select-authenticator/index.vue deleted file mode 100644 index 3364039..0000000 --- a/src/views/select-authenticator/index.vue +++ /dev/null @@ -1,143 +0,0 @@ - - - diff --git a/src/views/webauthn-authenticate/index.vue b/src/views/webauthn-authenticate/index.vue index d955d32..ed6a2e8 100644 --- a/src/views/webauthn-authenticate/index.vue +++ b/src/views/webauthn-authenticate/index.vue @@ -84,7 +84,6 @@ import Layout from "~/components/Layout.vue"; import ErrorBox from "~/components/ErrorBox.vue"; import type { KcContextBase } from "~/types/context"; import { base64url } from "rfc4648"; -import { formPost } from "~/functions/utils"; export default defineComponent({ name: "WebAuthnAuthenticate", @@ -107,7 +106,7 @@ export default defineComponent({ methods: { tryAnotherWay(e: Event) { e.preventDefault(); - formPost(this.context.url.loginAction, { + this.formPost(this.context.url.loginAction, { tryAnotherWay: "on", }); }, @@ -167,7 +166,7 @@ export default defineComponent({ ), }; - formPost(this.context.url.loginAction, postData); + this.formPost(this.context.url.loginAction, postData); } catch (err) { this.error = true; } @@ -175,6 +174,24 @@ export default defineComponent({ retryAuth() { this.error = false; }, + formPost(url: string, data: object) { + const form = document.createElement("form"); + form.method = "post"; + form.action = url; + + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + const hiddenField = document.createElement("input"); + hiddenField.type = "hidden"; + hiddenField.name = key; + hiddenField.value = data[key]; + + form.appendChild(hiddenField); + } + } + document.body.appendChild(form); + form.submit(); + }, }, }); diff --git a/webpack.config.js b/webpack.config.js index 3ac5daf..ba34e35 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,12 +5,7 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const THEME_NAME = "modern-login"; -const customPages = [ - "login", - "webauthn-authenticate", - "saml-post-form", - "select-authenticator" -]; +const customPages = ["login", "webauthn-authenticate", "saml-post-form"]; module.exports = function (env, argv) { const isDevelopment = argv.mode !== "production";