~sircmpwn/builds.sr.ht

builds.sr.ht/buildsrht/templates/secrets.html -rw-r--r-- 5.9 KiB
0467110eDrew DeVault qemu: upgrade to 7.0.0 7 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{% extends "layout.html" %}
{% block content %} 
<section class="row">
  <div class="col-md-4">
    <p>
      You can incorporate secrets (like SSH keys) into your builds by including
      their UUIDs in your build manifest:
    </p>
    <pre>secrets:
- 46f739e5-4538-45dd-a79f-bf173b7a2ed9</pre>
    <h3>Add new secret</h3>
    <form method="POST" action="/secrets" enctype="multipart/form-data">
      {{csrf_token()}}
      <div class="form-group">
        <label for="name">Name</label>
        <input
          id="name"
          name="name"
          type="text"
          placeholder="Optional"
          class="form-control {{ valid.cls("name") }}"
          value="{{ name or "" }}" />
        {{ valid.summary("name") }}
      </div>
      <div class="form-group">
        <label for="secret">Secret</label>
        <textarea
          id="secret"
          name="secret"
          class="form-control {{ valid.cls("secret") }}"
          rows="5"></textarea>
        {{ valid.summary("secret") }}
      </div>
      <fieldset class="form-group">
        <legend>Secret Type</legend>
        <div class="form-check form-check-inline">
          <label class="form-check-label">
            <input
              class="form-check-input"
              type="radio"
              name="secret_type"
              id="secret_type-ssh_key"
              value="ssh_key"
              {{ "checked" if secret_type == "ssh_key" else "" }}> SSH Key
          </label>
        </div>
        <div class="form-check form-check-inline">
          <label class="form-check-label">
            <input
              class="form-check-input"
              type="radio"
              name="secret_type"
              id="secret_type-pgp_key"
              value="pgp_key"
              {{ "checked" if secret_type == "pgp_key" else "" }}> PGP Key
          </label>
        </div>
        <div class="form-check form-check-inline">
          <label class="form-check-label">
            <input
              class="form-check-input"
              type="radio"
              name="secret_type"
              id="secret_type-plaintext_file"
              value="plaintext_file"
              {{ "checked" if secret_type == "plaintext_file" else "" }}> File
          </label>
        </div>
        {# XXX: Hack to appease Bootstrap #}
        <div class="form-control d-none {{ valid.cls("secret_type") }}"></div>
        {{ valid.summary("secret_type") }}
        <noscript>
          <p>The following fields only apply to "File" secrets:</p>
        </noscript>
        <div id="file-fields">
          <div class="form-group">
            <label for="file-path">Path</label>
            <input
              type="text"
              class="form-control {{ valid.cls("file-path") }}"
              name="file-path"
              placeholder="e.g. '~/.my_secret'" />
            {{ valid.summary("file-path") }}
          </div>
          <div class="form-group">
            <label for="file-mode">Mode</label>
            <input
              type="text"
              class="form-control {{ valid.cls("file-mode") }}"
              name="file-mode"
              placeholder="e.g. '644'" />
            {{ valid.summary("file-mode") }}
          </div>
          <div class="form-group">
            <label for="file-file">File</label>
            <input
              type="file"
              class="form-control {{ valid.cls("file-file") }}"
              name="file-file"
              aria-describedby="file-file-help"
              />
            {{ valid.summary("file-file") }}
            <small
              id="file-file-help"
              class="form-text text-muted"
            >
              Choose a file here <strong>or</strong> paste the text in above,
              not both.
            </small>
          </div>
        </div>
        <script>
          // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-only
          (function() {
            var fields = document.getElementById("file-fields");
            var checkbox = document.getElementById("secret_type-plaintext_file");

            function apply() {
              console.log("apply", checkbox.checked);
              fields.style.display = checkbox.checked ? "block" : "none";
            };

            [].slice.call(document.querySelectorAll("input[type='radio']")).map(function(radio) {
              radio.addEventListener("change", apply);
            });
            apply();
          })();
          // @license-end
        </script>
        <p>
          SSH keys are written to <code>~/.ssh/:uuid</code> and the first key
          added is symlinked to <code>~/.ssh/id_rsa</code>. PGP keys are
          imported into GPG.
        </p>
      </fieldset>
      <button type="submit" class="btn btn-primary btn-block">
        Add secret {{icon("caret-right")}}
      </button>
    </form>
  </div>
  <div class="col-md-8">
    {% if message %}
    <div class="alert alert-info">
      {{ message }}
    </div>
    {% endif %}
    {% if len(secrets) == 0 %}
    <div class="alert alert-info">You haven't added any secrets yet.</div>
    {% else %}
    <div class="event-list">
      {% for secret in secrets %}
      <div class="event">
        <h4>
          <code style="padding: 0;">{{ secret.uuid }}</code>
          <small class="pull-right">{{ secret.created | date }}</small>
        </h4>
        {% if secret.name %}
        <div>{{ secret.name }}</div>
        {% endif %}
        <a
          href="/secret/delete/{{ secret.uuid }}"
          class="btn btn-danger pull-right"
        >Delete</a>
        <div>
          {{secret.secret_type.pretty_name}}{%
            if secret.secret_type.value == "plaintext_file"
          %}:
          <code>
            {{secret.path}}
            {{"{0:0o}".format(secret.mode)}}
          </code>
          {% endif %}
        </div>
        <div class="clearfix"></div>
      </div>
      {% endfor %}
    </div>
    {% endif %}
  </div>
</section>
{% endblock %}