summaryrefslogtreecommitdiffstats
path: root/templates/login.html.template
blob: ae0874abedcf71ea04bf4af6d4c9faa4b567ae84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!-- Copyright 2026 Rose Hogenson <r@roseh.moe>
  --
  -- This file is part of roseh.moe.
  --
  -- roseh.moe is free software: you can redistribute it and/or modify
  -- it under the terms of the GNU Affero General Public License
  -- as published by the Free Software Foundation, either version 3 of
  -- the License, or (at your option) any later version.
  --
  -- roseh.moe is distributed in the hope that it will be useful,
  -- but WITHOUT ANY WARRANTY; without even the implied warranty
  -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  -- GNU Affero General Public License for more details.
  --
  -- You should have received a copy of the GNU Affero General Public
  -- License along with roseh.moe. If not, see
  -- <https://www.gnu.org/licenses/>.
  -->

<!doctype html>

<form id="form" method="post">
	<input id="user"        type="hidden" name="user">
	<input id="auth-data"   type="hidden" name="auth-data">
	<input id="client-data" type="hidden" name="client-data">
	<input id="sig"         type="hidden" name="sig">
</form>

<script>
async function main() {
	const publicKeyCredential = await navigator.credentials.get({publicKey: {
		challenge: Uint8Array.fromBase64("{{.Challenge}}").buffer,
	}});
	const rsp = publicKeyCredential.response;
	document.getElementById("user").value = new Uint8Array(rsp.userHandle).toBase64();
	document.getElementById("auth-data").value = new Uint8Array(rsp.authenticatorData).toBase64();
	document.getElementById("client-data").value = new Uint8Array(rsp.clientDataJSON).toBase64();
	document.getElementById("sig").value = new Uint8Array(rsp.signature).toBase64();
	document.getElementById("form").submit();
}

main();
</script>

This page requires JavaScriptâ„¢ to be enabled