First step of milestone 461 (MCP server). A token is the credential an MCP client presents as `Authorization: Bearer stw_…` to act as its user. - api_tokens table (0026): sha256 hash only, display prefix, role ceiling, expiry, revocation, throttled last_used_at. - steward/core/api_tokens.py: mint, list, revoke, resolve. Resolution re-reads the user's current role and acts with the lower of that and the token's ceiling, so demoting or disabling a user weakens or kills their tokens with nothing to revoke by hand. - /ai-access/ (sidebar → Automation → AI access): every user manages their own tokens, can't grant above their own role, sees the token once. Session-only: a share-link viewer is refused. Create and revoke are audited. - Integration tests drive the routes against real Postgres so their transactions run for real (#884 escaped CI behind a mocked session). Task #4965 "MCP-1 — Personal API tokens". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.8 KiB
HTML
39 lines
1.8 KiB
HTML
{% extends "base.html" %}
|
|
{% from "_macros.html" import crumbs %}
|
|
{% block title %}Token created — Steward{% endblock %}
|
|
{% block breadcrumb %}{{ crumbs([("AI access", "/ai-access/"), ("Token created", "")]) }}{% endblock %}
|
|
{% block content %}
|
|
<div style="max-width:640px;">
|
|
<h1 class="page-title">Token created</h1>
|
|
|
|
<div class="card" style="border-color:var(--gold);margin-bottom:1rem;">
|
|
<div style="font-size:0.8rem;font-weight:600;color:var(--gold);text-transform:uppercase;letter-spacing:0.06em;margin-bottom:0.75rem;">
|
|
Copy this token now. It can't be shown again.
|
|
</div>
|
|
|
|
<div style="display:flex;gap:0.5rem;align-items:center;">
|
|
<input type="text" id="api-token" value="{{ raw_token }}" readonly
|
|
aria-label="API token"
|
|
style="flex:1;font-family:ui-monospace,monospace;font-size:0.8rem;background:var(--bg);color:var(--text);">
|
|
<button type="button"
|
|
onclick="navigator.clipboard.writeText(document.getElementById('api-token').value).then(()=>this.textContent='Copied')"
|
|
class="btn btn-ghost btn-sm" style="white-space:nowrap;">Copy</button>
|
|
</div>
|
|
|
|
<div style="margin-top:0.75rem;font-size:0.82rem;color:var(--text-muted);">
|
|
<strong>Name:</strong> {{ token.name }}
|
|
· <strong>Role:</strong> {{ token.role.value }}
|
|
· <strong>Expires:</strong>
|
|
{% if token.expires_at %}{{ token.expires_at.strftime("%Y-%m-%d") }}{% else %}Never{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<p style="font-size:0.85rem;color:var(--text-muted);line-height:1.55;">
|
|
Treat it like a password: anyone holding it can act as you, up to this token's role.
|
|
If it leaks, revoke it from the AI access page.
|
|
</p>
|
|
|
|
<a href="/ai-access/" class="btn btn-ghost">Back to AI access</a>
|
|
</div>
|
|
{% endblock %}
|