~cytrogen/srht-deploy

ref: 6b7b1351f3bd75526788ceec9164562787bd89ae srht-deploy/meta-custom/templates/keys.html -rw-r--r-- 4.9 KiB
6b7b1351 — Cytrogen 修复 README 里的 Markdown 格式错误 9 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{% extends "meta.html" %}
{% block title %}
<title>密钥管理 - {{cfg("sr.ht", "site-name")}} meta</title>
{% endblock %}
{% block content %}
<div class="row">
  <div class="col-md-12 event-list">
    <section class="event">
      <h3>SSH 密钥</h3>
      {% if any(current_user.ssh_keys) %}
      <p>以下 SSH 密钥已关联到你的账户:</p>
      <table class="table">
        <thead>
          <tr>
            <th>名称</th>
            <th>指纹</th>
            <th>添加时间</th>
            <th>最后使用</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for key in current_user.ssh_keys %}
          <tr>
            <td>{{key.comment}}</td>
            <td>{{key.fingerprint}}</td>
            <td>{{key.created|date}}</td>
            <td>{{key.last_used|date}}</td>
            <td style="width: 6rem">
              <form method="POST" action="/keys/delete-ssh/{{key.id}}">
                {{csrf_token()}}
                <button type="submit" class="btn btn-danger btn-fill">
                  删除
                </button>
              </form>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      {% endif %}
      <form method="POST" action="/keys/ssh-keys">
        {{csrf_token()}}
        <div class="form-group">
          <label for="ssh-key">SSH 公钥:</label>
          <input
            type="text"
            class="form-control {{valid.cls("ssh-key")}}"
            id="ssh-key"
            name="ssh-key"
            aria-describedBy="sshkey-details"
            value="{{ssh_key or ""}}"
            placeholder="ssh-ed25519 bWFyYmxlY2FrZQo= ..." />
          <small id="sshkey-details" class="form-text text-muted">
            你的 SSH 公钥列表可通过
            <a
              href="{{url_for("profile.user_keys_GET",
                username=current_user.username)}}"
            >{{current_user.canonical_name}}.keys</a> 公开访问
          </small>
          {{valid.summary("ssh-key")}}
        </div>
        {{valid.summary()}}
        <button type="submit" class="btn btn-primary pull-right">
          添加密钥 {{icon("caret-right")}}
        </button>
      </form>
    </section>
    <section class="event">
      <h3>PGP 密钥</h3>
      {% if any(current_user.pgp_keys) %}
      <p>以下 PGP 密钥已关联到你的账户:</p>
      <table class="table">
        <thead>
          <tr>
            <th>指纹</th>
            <th>添加时间</th>
            <th>过期时间</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for key in current_user.pgp_keys %}
          <tr>
            <td>{{key.fingerprint_hex}}</td>
            <td>{{key.created|date}}</td>
            {% if not key.expiration %}
            <td>永不过期</td>
            {% elif key.expiration > now %}
            <td>{{key.expiration|date}}</td>
            {% else %}
            <td><span class="text-danger">已过期 {{key.expiration|date}}</span></td>
            {% endif %}
            <td style="width: 6rem">
              <form method="POST" action="/keys/delete-pgp/{{key.id}}">
                {{csrf_token()}}
                <button type="submit" class="btn btn-danger btn-fill">删除</button>
              </form>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      {% endif %}
      {% if tried_to_delete_key_in_use %}
      <div class="alert alert-danger">此密钥当前用于邮件加密。请先在
          <a href="/privacy">隐私设置</a>中选择其他密钥或禁用邮件加密,
          然后再删除此密钥。</div>
      {% endif %}
      <form method="POST" action="/keys/pgp-keys">
        {{csrf_token()}}
        <div class="form-group">
          <label for="pgp-key">PGP 公钥:</label>
          <textarea
            class="form-control {{valid.cls("pgp-key")}}"
            id="pgp-key"
            name="pgp-key"
            style="font-family: monospace"
            rows="5"
            placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----
[...]
-----END PGP PUBLIC KEY BLOCK-----"
          >{{pgp_key or ""}}</textarea>
          <div id="gpg-command-section" class="form-text text-muted">
            你可以使用以下命令导出 PGP 密钥:<br>
            <code id="gpg-command">gpg --armor --export-options export-minimal --export {{email or current_user.email}}</code>
          </div>
          <small id="sshkey-details" class="form-text text-muted">
            你的 PGP 公钥列表可通过
            <a
              href="{{url_for("profile.user_pgp_keys_GET",
                username=current_user.username)}}"
            >{{current_user.canonical_name}}.pgp</a> 公开访问
          </small>
          {{valid.summary("pgp-key")}}
        </div>
        <button type="submit" class="btn btn-primary pull-right">
          添加密钥 {{icon("caret-right")}}
        </button>
      </form>
    </section>
  </div>
</div>
{% endblock %}