summaryrefslogtreecommitdiffstats
path: root/template/en/default/account/prefs/apikey.html.tmpl
blob: cdbee848bc6b2a00cc9376e6b799c89e7dc9aa5c (plain)
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
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[%# INTERFACE:
  # api_keys: array. Array of api keys this user has.
  # any_revoked: boolean. True is any keys have been revoked.
  #%]

<p>
  API keys are used to authenticate WebService API calls. You can create more than
  one API key if required. Each API key has an optional description which can help
  you record what each key is used for.<br>
  <br>
  Documentation on how to log in is available
  <a href="https://bmo.readthedocs.org/en/latest/api/core/v1/general.html#authentication">
    here</a>.
</p>

<h3>Existing API keys</h3>

<p>You can update the description, and revoke or unrevoke existing API keys
here.</p>

<table id="email_prefs">
  <tr class="column_header">
    <th>API key</th>
    <th>Description (optional)</th>
    <th>Last used</th>
    <th>Revoked</th>
  </tr>

  [%# because mozreview api-keys only work for the mozreview api, we hide the
    # key and prevent renaming #%]
  [% FOREACH api_key IN api_keys %]
    <tr[% IF api_key.revoked %] class="apikey_revoked bz_tui_hidden" style="display:none"[% END %]>
      <td>
        [% IF api_key.is_mozreview %]
          <i>hidden</i>
        [% ELSE %]
          [% api_key.api_key FILTER html %]
        [% END %]
      </td>
      <td>
        [% IF api_key.is_mozreview %]
            MozReview
        [% ELSE %]
          <input name="description_[% api_key.id FILTER html %]"
            id="description_[% api_key.id FILTER html %]"
            value="[% api_key.description FILTER html %]">
        [% END %]
      </td>
      [% IF api_key.last_used %]
        <td>[% api_key.last_used FILTER time %]
          [% IF api_key.last_used_ip %] ([% api_key.last_used_ip FILTER html %]) [% END %]
        </td>
      [% ELSE %]
        <td class="center"><i>never used</i></td>
      [% END %]
      <td class="center">
        <input type="checkbox" value="1"
          name="revoked_[% api_key.id FILTER html %]"
          id="revoked_[% api_key.id FILTER html %]"
          [% IF api_key.revoked %] checked="checked" [% END %]>
        [% IF api_key.revoked %]
          [% INCLUDE "mfa/protected.html.tmpl" %]
        [% END %]
      </td>
    </tr>
  [% END %]
  [% UNLESS api_keys.size %]
    <tr><td colspan="4">You don't have any API keys.</td></tr>
  [% END %]
</table>

[% IF any_revoked %]
  <a href="#" id="apikey-toggle-revoked">Show Revoked Keys</a>
[% END %]

<h3>New API key</h3>

<p>You can generate a new API key by ticking the check box below and optionally
providing a description for the API key. The API key will be randomly
generated for you.</p>

<p>
  <input type="checkbox" name="new_key" id="new_key">
  <label for="new_key">
    Generate a new API key with optional description</label>
  <input name="new_description" id="new_description">
  [% INCLUDE "mfa/protected.html.tmpl" %]
</p>