1{{ define "title" }}API tokens — settings{{ end }} {{ define "navextra" }}<a href="/settings/keys">SSH keys</a>
2<a href="/settings/mtls">mTLS</a> <a href="/settings/token">API tokens</a>{{ end
3}} {{ define "srv_settings_token.html" }}{{ template "head" . }}
4<div class="container">
5 <h2 style="margin-bottom: 4px">API tokens</h2>
6 <p style="font-size: 13px; color: #666; margin-bottom: 16px">
7 API tokens let <code>arche</code> authenticate to this server without a
8 password. Use them in <code>~/.config/arche/config.toml</code> as the
9 <code>remote.token</code> value, or pass via
10 <code>Authorization: Bearer <token></code>.
11 </p>
12 {{ if .Error }}
13 <p class="error">{{.Error}}</p>
14 {{ end }} {{ if .NewToken }}
15 <div style="background: #e8f5e9;
16 border: 1px solid #a5d6a7;
17 border-radius: 3px;
18 padding: 12px 16px;
19 margin-bottom: 20px">
20 <p style="font-size: 13px; color: #2e7d32; margin-bottom: 6px">
21 <strong>New token created — copy it now, it won't be shown again:</strong>
22 </p>
23 <code style="font-size: 13px;
24 word-break: break-all;
25 background: #fff;
26 display: block;
27 padding: 8px;
28 border-radius: 2px;
29 border: 1px solid #c8e6c9">{{.NewToken}}</code>
30 </div>
31 {{ end }} {{ if .Tokens }}
32 <table style="margin-bottom: 24px">
33 <thead>
34 <tr>
35 <th>Label</th>
36 <th>Created</th>
37 <th></th>
38 </tr>
39 </thead>
40 <tbody>
41 {{ range .Tokens }}
42 <tr>
43 <td>
44 {{ if .Label }}{{.Label}}{{ else }}<span style="color: #aaa">—</span>{{ end }}
45 </td>
46 <td style="font-size: 12px; color: #888">{{.CreatedAt}}</td>
47 <td>
48 <button onclick="deleteToken({{.ID}})"
49 style="background: #c0392b;
50 font-size: 12px;
51 padding: 2px 8px">Revoke</button>
52 </td>
53 </tr>
54 {{ end }}
55 </tbody>
56 </table>
57{{ else }}
58 <p style="color: #888; margin-bottom: 24px">No API tokens yet.</p>
59 {{ end }}
60 <details>
61 <summary style="cursor: pointer; font-size: 13px; color: #555">Create new token</summary>
62 <form method="post" action="/settings/tokens" style="margin-top: 12px">
63 <div class="field">
64 <label>Label (optional)</label>
65 <input type="text"
66 name="label"
67 style="width: 280px"
68 placeholder="e.g. laptop, CI" />
69 </div>
70 <button type="submit">Create token</button>
71 </form>
72 </details>
73</div>
74<script>
75 function deleteToken(id) {
76 if (!confirm("Revoke this token? Any scripts using it will stop working."))
77 return;
78 fetch("/settings/tokens/" + id, { method: "DELETE" }).then(function (r) {
79 if (r.ok) {
80 location.reload();
81 } else {
82 r.text().then(alert);
83 }
84 });
85 }
86</script>
87{{ template "foot" . }} {{ end }}