From 41e571dce97b098cac7256d4e61f84854435c539 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 1 Jul 2025 22:10:02 +0200 Subject: disable password log by auto-redirect to sso --- inject/disable-password-login.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 inject/disable-password-login.js (limited to 'inject/disable-password-login.js') diff --git a/inject/disable-password-login.js b/inject/disable-password-login.js new file mode 100644 index 0000000..529e158 --- /dev/null +++ b/inject/disable-password-login.js @@ -0,0 +1,22 @@ +export function disablePasswordLogin() { + const queryString = new URLSearchParams(); + if (queryString.get("all") == null) { + document.addEventListener("DOMContentLoaded", function () { + const sso = document.querySelector(".o_auth_oauth_providers"); + if (sso) { + const link = sso.getElementsByTagName("a")[0]; + if (link.innerText.search("Authentik") > 0) { + console.info("Redirecting to SSO login:", link.href); + // Disable for now while we don't have a way to prevent redirection + // for e.g. admin login. One way would be to scan for presence of a + // query string parameter such as `pwauth`, but I could not get + // URLSearchParams to help me. + window.location.replace(link.href); + } + } + }); + } + else { + console.info("Not skipping password auth due to query string"); + } +} -- cgit v1.2.3 From 416c45f6fc4905cd96bf87879f7d0a427f87bfe3 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 15 Jul 2025 19:40:06 +0200 Subject: Fix ?pwauth disabling SSO redirect --- inject/disable-password-login.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'inject/disable-password-login.js') diff --git a/inject/disable-password-login.js b/inject/disable-password-login.js index 529e158..67ec68b 100644 --- a/inject/disable-password-login.js +++ b/inject/disable-password-login.js @@ -1,16 +1,13 @@ export function disablePasswordLogin() { - const queryString = new URLSearchParams(); - if (queryString.get("all") == null) { + const queryString = new URLSearchParams(window.location.search); + console.log(queryString); + if (queryString.get("pwauth") == null) { document.addEventListener("DOMContentLoaded", function () { const sso = document.querySelector(".o_auth_oauth_providers"); if (sso) { const link = sso.getElementsByTagName("a")[0]; - if (link.innerText.search("Authentik") > 0) { + if (link.innerText.search("Authentik") + link.innerText.search("TONI SSO") > 0) { console.info("Redirecting to SSO login:", link.href); - // Disable for now while we don't have a way to prevent redirection - // for e.g. admin login. One way would be to scan for presence of a - // query string parameter such as `pwauth`, but I could not get - // URLSearchParams to help me. window.location.replace(link.href); } } -- cgit v1.2.3