Can now run as a Ory Hydra login and consent app

This commit is contained in:
2023-11-03 18:18:25 +01:00
parent 6498a8bd06
commit 805bfe56db
9 changed files with 226 additions and 5 deletions

View File

@@ -3,9 +3,10 @@
<head>
<meta charset="UTF-8">
<title>SSO Login</title>
<script src="/login/login.js"></script>
</head>
<body>
<form action="password" method="post">
<form method="post">
<table>
<tr>
<td><label for="user">User</label></td>
@@ -18,7 +19,7 @@
<tr>
<td></td>
<td>
<input type="submit" value="Log in">
<input type="submit" value="Log in" id="doit">
</td>
</tr>
</table>

View File

@@ -0,0 +1,33 @@
// Attempt to log in using ambient authority (e.g., Kerberos, SSL, etc)
async function tryLoginAmbient() {
let resp = await fetch("/login/krb5" + window.location.search, {method: "POST", redirect: "manual"})
if (resp.ok) {
window.location = await resp.text()
}
}
async function tryLoginPassword() {
let userField = document.getElementById("user")
let passwordField = document.getElementById("password")
let doit = document.getElementById("doit")
try {
userField.enabled = passwordField.enabled = doit.enabled = false
let resp = await fetch("/login/password" + window.location.search, {method: "POST"})
if (resp.ok) {
window.location = await resp.text()
}
} catch (e) {
userField.enabled = passwordField.enabled = doit.enabled = true
throw e
}
}
tryLoginAmbient() // don't bother awaiting, just let 'er go
document.addEventListener("load", () => {
document.getElementById("doit").form.addEventListener("submit", function (e) {
e.preventDefault()
tryLoginPassword()
return false
})
})

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Consent request</title>
</head>
<body>
<pre>{{ .ConsentRequest }}</pre>
<hr>
</body>
</html>

View File

@@ -0,0 +1 @@
{{ .ConsentRequest }}