Dashboard: an API key button that shows the key with a copy button
Behind the same sign-in as the rest of the dashboard (GET /api/key, no-store), so whoever can open the dashboard can hand the key to a client without a shell on the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e814a2359d
commit
6fd82448c5
4 changed files with 58 additions and 3 deletions
|
|
@ -98,6 +98,10 @@ check("config reports key mode", st == 200 and json.loads(body)["mode"] == "key"
|
|||
check("status without key -> 401", req(srv, "GET", "/api/status")[0] == 401)
|
||||
check("status with key -> 200", req(srv, "GET", "/api/status", {"Authorization": f"Bearer {KEY}"})[0] == 200)
|
||||
check("no /auth/login without OIDC", req(srv, "GET", "/auth/login")[0] == 404)
|
||||
check("/api/key needs the key", req(srv, "GET", "/api/key")[0] == 401)
|
||||
st, h, body, _ = req(srv, "GET", "/api/key", {"Authorization": f"Bearer {KEY}"})
|
||||
check("/api/key returns it", st == 200 and json.loads(body) == {"key": KEY}, body)
|
||||
check("/api/key isn't cached", h.get("cache-control") == "no-store", h)
|
||||
srv.shutdown()
|
||||
|
||||
print("\n2. OIDC mode refuses the key and unsigned visitors")
|
||||
|
|
@ -165,6 +169,10 @@ st, _, _, _ = req(srv, "POST", "/api/stats/reset", {**PUB_HOST, "Cookie": sess,
|
|||
check("POST from another origin -> 403", st == 403, st)
|
||||
st, _, _, _ = req(srv, "POST", "/api/stats/reset", {**PUB_HOST, "Cookie": sess, "Origin": PUBLIC})
|
||||
check("POST from the dashboard's origin -> 200", st == 200, st)
|
||||
check("/api/key refused without a session", req(srv, "GET", "/api/key", PUB_HOST)[0] == 401)
|
||||
check("/api/key refused for the key alone", req(srv, "GET", "/api/key", {**PUB_HOST, "Authorization": f"Bearer {KEY}"})[0] == 401)
|
||||
st, _, body, _ = req(srv, "GET", "/api/key", {**PUB_HOST, "Cookie": sess})
|
||||
check("signed in: /api/key returns it", st == 200 and json.loads(body) == {"key": KEY}, body)
|
||||
check("only the session's hash is stored", sess.split("=", 1)[1] not in o.sessions)
|
||||
|
||||
print("\n5. sign-ins that must fail")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue