Skip to content

Commit b8c2afd

Browse files
authored
Do not show passkey on http sites (#33820)
Fix #33615
1 parent 582ad33 commit b8c2afd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

web_src/js/features/user-auth-webauthn.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {encodeURLEncodedBase64, decodeURLEncodedBase64} from '../utils.ts';
2-
import {showElem} from '../utils/dom.ts';
2+
import {hideElem, showElem} from '../utils/dom.ts';
33
import {GET, POST} from '../modules/fetch.ts';
44

55
const {appSubUrl} = window.config;
@@ -11,6 +11,15 @@ export async function initUserAuthWebAuthn() {
1111
return;
1212
}
1313

14+
if (window.location.protocol === 'http:') {
15+
// webauthn is only supported on secure contexts
16+
const isLocalhost = ['localhost', '127.0.0.1'].includes(window.location.hostname);
17+
if (!isLocalhost) {
18+
hideElem(elSignInPasskeyBtn);
19+
return;
20+
}
21+
}
22+
1423
if (!detectWebAuthnSupport()) {
1524
return;
1625
}

0 commit comments

Comments
 (0)