Files
ilkerandClaude Opus 5 5d398c9429 hpcod: sign up on the site, and nobody gets in until someone says so
The front page asked people to send an email, which is not a process - it
is a hope that somebody reads their inbox. Anyone can register now, nobody
is let in by registering, and an administrator decides.

Accounts move from the htpasswd-style file into the database, because a
file read once at startup cannot take a registration. The file stays as
the bootstrap: an account in it is an administrator, which is how the
portal is brought up at all, and someone who can write that file has the
machine anyway.

The safety rests on two column defaults rather than on care in a handler.
A new row is 'pending' and is not an administrator, and the signup INSERT
names neither column - so no mistake in the code above can produce a live
account. The handler checks anyway and disables anything that comes back
usable, which is for the day someone changes the defaults.

What the tests pin down, because these are the parts that would be quietly
wrong:

  - a registration yields state=pending, is_admin=false, no decision
  - a pending or disabled account cannot sign in, even with the right password
  - a wrong password says exactly what it says for an unknown username, so
    the "awaiting approval" message cannot be used to find out who exists
  - only a verified password ever gets a specific reason
  - approving does not also grant administrator rights; they are separate
    decisions and conflating them is how someone gets more than was meant
  - an administrator cannot decide on their own account, which would either
    do nothing or lock the last one out
  - the admin page 404s for a signed-in non-admin rather than 403, and its
    link is not rendered for them either
  - the password column refuses anything that is not a bcrypt hash, so a
    caller that forgot to hash cannot store a plaintext password
  - a decision without a name is refused by a CHECK, because an audit trail
    with holes in it is not one

The password hash is not a field on Account. Everything that renders an
account would carry it; only the code comparing a password has a reason to
see it, so only that call returns it.

hpcod account is the way in when the portal is not: the first administrator
has to come from somewhere, and an operator who has locked themselves out
still has a shell.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 08:13:34 +02:00

52 lines
2.3 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{define "signup.html"}}<!doctype html>
<html lang="en"><head>{{template "head" .}}<title>Request access · HPC on Demand</title>
<style>
.narrow{max-width:520px}
label{display:block;font-size:12.5px;font-weight:500;margin:14px 0 4px}
input[type=text],input[type=email],input[type=password],textarea.one{width:100%;padding:8px 10px;
border:1px solid var(--rule);border-radius:4px;background:var(--surface);color:var(--ink);font:inherit}
textarea.one{min-height:76px;font-family:var(--sans);font-size:14px}
.hint{font-size:12px;color:var(--muted);margin-top:4px}
</style>
</head>
<body>
<main class="narrow">
<h1>Request access</h1>
<p class="deck">Register here and an administrator decides. Your account will
not work until it is approved — signing in before then tells you so.</p>
{{if .Done}}
<div class="note"><p><strong>Registered.</strong> Nothing to do now but wait
for an administrator to approve the account. Once they have, sign in
normally — there is no confirmation email.</p></div>
<p><a href="/">Back to the front page</a></p>
{{else}}
{{if .Err}}<div class="note crit"><p>{{.Err}}</p></div>{{end}}
{{if eq .Page "signup"}}
<form method="post" action="/signup" class="card"><div class="card-b">
<label for="u">Username</label>
<input id="u" name="username" type="text" required autofocus
value="{{index .Form "username"}}" autocomplete="username">
<div class="hint">3–32 characters: letters, digits, dot, dash, underscore.</div>
<label for="p">Password</label>
<input id="p" name="password" type="password" required autocomplete="new-password">
<div class="hint">At least 12 characters. Length is what makes one hard to guess.</div>
<label for="e">Email</label>
<input id="e" name="email" type="email" value="{{index .Form "email"}}" autocomplete="email">
<div class="hint">Optional, and only so an administrator can reach you.</div>
<label for="r">What do you need a cluster for?</label>
<textarea id="r" name="reason" class="one" required>{{index .Form "reason"}}</textarea>
<div class="hint">The only thing the approver has to go on.</div>
<button type="submit">Register</button>
</div></form>
<p class="age">Already approved? <a href="/login">Sign in</a>.</p>
{{end}}
{{end}}
</main>
</body></html>
{{end}}