hub v0.152.0: operator access tokens with scopes (09 §3 decision 251, operator 2026-10-15 11:38)
gates / gates (push) Successful in 6m44s

- Configuration → Access tokens: named, scoped (group read/write), expiring (≤365 d), shown once,
  stored SHA-256 only, every use logged by name. Bearer fhp_… on the web surface only; /api/v1 refuses it.
- Route table = the code's single source (web/routes.go), pinned to ServeHTTP's switch; session-only:
  secrets shown/minted, deletes/resets, password, tokens.
- R-952 closed: /api/v1 route table names each caller, pinned to the switch; no-credential refusal test.
- Fail-open fixed: an empty operator password served the UI open (main skipped RequireAuth). Live hub never open.
- 05 §17, 04 §6.2, 13, 09 §3 251; register 155→157 (+R-1054, R-1055, R-1056, −R-952); STATUS.
- website: prowlarr-logo.svg (byte copy from felhom.eu-media) — the site gate refused every push.
Not deployed — waits for the operator's yes.

Claude-Session: https://claude.ai/code/session_012qRErfCoiTkvDK9N5XHbzb
This commit is contained in:
admin committed 2026-10-15 12:20:35 +02:00
1 parent e92501f5a1
commit d62cc08b2e
37 files changed
+2567 -21

No files matched your search

@@ -284,6 +284,77 @@
</script>
</section>
<!-- Access tokens (v0.152.0, `05` §17): scoped, expiring stand-ins for the operator password, for scripts.
Managed only from a browser session — ShowTokens is false when a token reads this page. -->
{{if .ShowTokens}}
<section class="card" id="tokens">
<h3 style="margin-top: 0;">Access tokens</h3>
<p class="text-muted">
A token lets a script use the hub without your password. Tick what it may do; it can do nothing else.
<strong>Never by any token:</strong> showing a box's emergency root password or a household's passphrase,
deleting or resetting a customer or host, changing the password, creating or revoking tokens.
Write includes read. The hub keeps only a scrambled form of each token, and logs every use by name.
</p>
{{if eq .Flash "token_revoked"}}<div class="flash flash-success">Token revoked. It stops working now.</div>{{end}}
{{if eq .Flash "token_name_invalid"}}<div class="flash flash-error">The token needs a name (at most 64 characters). Nothing was created.</div>{{end}}
{{if eq .Flash "token_no_scope"}}<div class="flash flash-error">Tick at least one permission. Nothing was created.</div>{{end}}
{{if eq .Flash "token_scope_invalid"}}<div class="flash flash-error">Unknown permission. Nothing was created.</div>{{end}}
{{if eq .Flash "token_days_invalid"}}<div class="flash flash-error">Expiry must be 1 to 365 days. Nothing was created.</div>{{end}}
{{if eq .Flash "token_create_failed"}}<div class="flash flash-error">The token was not saved. Nothing was created.</div>{{end}}
{{if eq .Flash "token_revoke_failed"}}<div class="flash flash-error">The token was not revoked.</div>{{end}}
{{with .CreatedToken}}
<div class="flash flash-warn" id="token-created">
<strong>Token {{.Name}} created. Copy it now — it is shown only this once.</strong><br>
<code id="token-plain">{{.Plain}}</code>
<button type="button" class="btn btn-sm" onclick="navigator.clipboard.writeText(document.getElementById('token-plain').textContent)">Copy</button>
</div>
{{end}}
{{if .Tokens}}
<table class="data-table">
<thead><tr><th>Name</th><th>Permissions</th><th>Expires</th><th>Last used</th><th>From</th><th>State</th><th></th></tr></thead>
<tbody>
{{range .Tokens}}
<tr>
<td>{{.Name}}</td>
<td><code>{{.Scopes}}</code></td>
<td>{{.Expires}}</td>
<td>{{.LastUsed}}</td>
<td>{{.LastUsedFrom}}</td>
<td>{{if .Active}}<span class="badge badge-ok">{{.State}}</span>{{else}}<span class="badge badge-neutral">{{.State}}</span>{{end}}</td>
<td>{{if .Active}}<form method="POST" action="/configuration/tokens/{{.ID}}/revoke">{{$.CSRFField}}<button class="btn btn-sm" type="submit" data-confirm="Revoke the token {{.Name}}? Scripts using it stop working at once.">Revoke</button></form>{{end}}</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<p class="text-muted">No tokens yet.</p>
{{end}}
<form method="POST" action="/configuration/tokens" id="token-create-form">
{{.CSRFField}}
<h4>New token</h4>
<label>Name <input type="text" name="name" maxlength="64" required placeholder="cc-releases"></label>
<table class="data-table">
<thead><tr><th>Group</th><th>Read</th><th>Write</th></tr></thead>
<tbody>
{{range .TokenGroups}}
<tr>
<td>{{.Label}}</td>
<td>{{if .Read}}<label><input type="checkbox" name="scope" value="{{.Key}}:read"> <span class="text-muted">{{.ReadHelp}}</span></label>{{end}}</td>
<td>{{if .Write}}<label><input type="checkbox" name="scope" value="{{.Key}}:write"> <span class="text-muted">{{.WriteHelp}}</span></label>{{end}}</td>
</tr>
{{end}}
</tbody>
</table>
<label>Expires after
<select name="days">
{{range .TokenDays}}<option value="{{.}}"{{if eq . $.TokenDefaultDays}} selected{{end}}>{{.}} days</option>{{end}}
</select>
</label>
<button class="btn btn-sm" type="submit">Create token</button>
</form>
</section>
{{end}}
<!-- Assets section -->
<section class="card">
<h3 style="margin-top: 0;">Assets</h3>