daybook/templates/artifacts/settings_users.html
peter 19c1798f90 Release v0.2.0: multiple named API keys per user
Replaces the single per-user DRF token with named, individually-revocable
API keys, so you can run one key per agent and cut off a leaked one without
disrupting the others.

- New ApiKey model (user, name, dbk_-prefixed key, created_at, last_used_at).
  Data migration copies every existing authtoken 1:1 into a "default" named
  key with the same value, so no client (incl. the sibling test project's
  hardcoded test-user key) needs reconfiguring.
- Auth (resolve_token_user) resolves against ApiKey and stamps last_used_at,
  throttled to one write/minute.
- Settings -> API Keys: table with name/key/created/last-used + per-row
  revoke and a create form; keys viewable on demand. Settings -> Account now
  links here; Settings -> Users issues a named initial key.
- Gated provisioning API for test installations: GET/POST /api/keys and
  DELETE /api/keys/{id}, controlled by DAYBOOK_KEY_PROVISIONING_API (unset ->
  follows DEBUG, so off in deployment). Advertised via key_provisioning_api
  in /api/capabilities; 403 when disabled.
- Docs (api/deployment/quickstart/posting-helper), SKILL.md, and env.example
  updated from "token / Settings -> Account" to "key / Settings -> API Keys".
- Tests: new API + UI suites for keys; existing token-based tests moved to
  ApiKey. Full suite 129 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-04 10:52:43 +01:00

32 lines
1.3 KiB
HTML

{% extends "artifacts/settings_base.html" %}
{% block settings_content %}
<h2>Users</h2>
{% if created_key %}
<p><strong>API key for {{ created_user.username }}</strong> (named "{{ created_key.name }}") — copy it now:</p>
<p><code class="token-value">{{ created_key.key }}</code></p>
<p class="muted">They can view, rename via new keys, and revoke it from Settings &rarr; API Keys.</p>
{% endif %}
<h3>Add User</h3>
<p>New users are regular accounts by default — they can log in and use their own API keys, but cannot reach Django admin unless you grant admin access below.</p>
<form method="post">
{% csrf_token %}
<p><label>Username<br><input type="text" name="username" required autocomplete="off"></label></p>
<p><label>Password<br><input type="password" name="password" required autocomplete="new-password"></label></p>
<p><label><input type="checkbox" name="is_superuser"> Grant admin access</label></p>
<button type="submit">Create User</button>
</form>
<h3>Existing Users</h3>
<ul class="storage-facts">
{% for user in users %}
<li>
{{ user.username }}{% if user == request.user %} (you){% endif %}
{% if user.is_superuser %} &mdash; admin{% endif %}
{% if not user.is_active %} &mdash; disabled{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}