~bigbes/sr-ht-spec

ref: 128d72963281e275bb1ec3be2bdb8653a2bb0c78 sr-ht-spec/web/templates/tokens.html -rw-r--r-- 2.1 KiB
128d7296 — Eugene Blikh ci: cache Go module and build dirs via cacher 13 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{{define "content"}}
<div class="row">
  <div class="col-md-12">
    <h2>Agent tokens</h2>
    <p>
      The credential an agent presents as
      <code>Authorization: Bearer &lt;token&gt;</code> to propose over the REST
      and MCP write planes. Only the stored hash lives in the database, so a
      token is shown exactly once — when it is minted.
    </p>

    {{if .Data.Minted}}
    <div class="alert alert-success">
      <p>
        <strong>{{.Data.MintedName}}</strong> minted. Copy it now &mdash; this is
        the only time it is shown.
      </p>
      <pre class="mb-0"><code>{{.Data.Minted}}</code></pre>
    </div>
    {{end}}

    <form method="POST" action="/tokens" class="form-inline mb-4">
      <div class="form-group">
        <label class="sr-only" for="name">Name</label>
        <input class="form-control" type="text" id="name" name="name"
               placeholder="which agent holds it" autocomplete="off" required>
      </div>
      <button class="btn btn-primary" type="submit">Mint token</button>
    </form>

    {{if .Data.Tokens}}
    <table class="table">
      <thead>
        <tr><th>Name</th><th>Created</th><th>State</th><th></th></tr>
      </thead>
      <tbody>
        {{range .Data.Tokens}}
        <tr>
          <td>{{.Name}}</td>
          <td class="text-muted"><code>{{.Created}}</code></td>
          <td>
            {{if .Active}}
            <span class="badge badge-success">active</span>
            {{else}}
            <span class="badge badge-danger">revoked</span>
            <small class="text-muted"><code>{{.Revoked}}</code></small>
            {{end}}
          </td>
          <td>
            {{if .Active}}
            <form method="POST" action="/tokens/{{.ID}}/revoke">
              <button type="submit" class="btn btn-sm btn-outline-danger">Revoke</button>
            </form>
            {{end}}
          </td>
        </tr>
        {{end}}
      </tbody>
    </table>
    {{else}}
    <p class="text-muted">
      No tokens yet. Without one the agent write plane refuses every caller as
      anonymous, so nothing can propose.
    </p>
    {{end}}
  </div>
</div>
{{end}}