1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 18:17:19 +00:00

Support disable passkey auth (#33348) (#33819)

* Backport #33348
* Backport #33820

---------

Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
wxiaoguang
2025-03-08 03:31:25 +08:00
committed by GitHub
parent 92f2d904f0
commit d03e7fd65e
8 changed files with 53 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import {encodeURLEncodedBase64, decodeURLEncodedBase64} from '../utils.ts';
import {showElem} from '../utils/dom.ts';
import {hideElem, showElem} from '../utils/dom.ts';
import {GET, POST} from '../modules/fetch.ts';
const {appSubUrl} = window.config;
@ -11,6 +11,15 @@ 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;
}
}
if (!detectWebAuthnSupport()) {
return;
}