From 28934fada8595e1cb1e64bbd0da99a46dfb3005e Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 Mar 2025 11:50:04 +0100 Subject: [PATCH] Simplify secure context check --- web_src/js/features/user-auth-webauthn.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/web_src/js/features/user-auth-webauthn.ts b/web_src/js/features/user-auth-webauthn.ts index e6c37581e01c8..1f336b9741f34 100644 --- a/web_src/js/features/user-auth-webauthn.ts +++ b/web_src/js/features/user-auth-webauthn.ts @@ -11,13 +11,10 @@ export async function initUserAuthWebAuthn() { return; } - if (window.location.protocol === 'http:') { - // webauthn is only supported on secure contexts - const isLocalhost = ['localhost', '127.0.0.1'].includes(window.location.hostname); - if (!isLocalhost) { - hideElem(elSignInPasskeyBtn); - return; - } + // webauthn is only supported on secure contexts + if (!window.isSecureContext) { + hideElem(elSignInPasskeyBtn); + return; } if (!detectWebAuthnSupport()) {