source: indico/indico/MaKaC/webinterface/tpls/UserAPI.tpl @ 14b949

hello-world-walkthroughipv6v0.98-seriesv0.98.2v0.98.3v0.98b2v0.99v1.0v1.1
Last change on this file since 14b949 was 14b949, checked in by Jose Benito <jose.benito.gonzalez@…>, 21 months ago

[IMP] Add request signature validation

  • Property mode set to 100644
File size: 4.8 KB
Line 
1<table class="groupTable">
2    <tr>
3        <td colspan="2">
4            <div class="groupTitle">${ _("HTTP API details") }</div>
5        </td>
6    </tr>
7    <tr>
8        <td class="dataCaptionTD"><span class="dataCaptionFormat">${ _("API Key")}</span></td>
9        <td class="blacktext">
10            ${apiKey.getKey() if apiKey else _('None')}
11            % if apiKey and apiKey.isBlocked():
12                <span class="warningText">Blocked ${inlineContextHelp(_('Your API key has been blocked. Please contact an administrator for details.'))}</span>
13            % endif
14        </td>
15    </tr>
16    <tr>
17        <td class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Signature Key")}</span></td>
18        <td class="blacktext">
19            ${apiKey.getSignKey() if apiKey else _('None')}
20            ${inlineContextHelp(_('To use your API key you must sign &quot;Path?QueryString&TS&quot; (TS=int(UnixTimestamp/300)) using HMAC-SHA1 and append it to the query string, e.g. &quot;Path?QueryString&SignatureHash&quot;'))}
21        </td>
22    </tr>
23    <tr>
24        <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Created")}</span></td>
25        <td class="blacktext">
26            ${formatDateTime(apiKey.getCreatedDT()) if apiKey else _('n/a')}
27        </td>
28    </tr>
29    <tr>
30        <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Last used")}</span></td>
31        <td class="blacktext">
32            ${apiKey.getLastUsedDT() and formatDateTime(apiKey.getLastUsedDT()) or 'Never' if apiKey else _('n/a')}
33        </td>
34    </tr>
35    <tr>
36        <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Last used by")}</span></td>
37        <td class="blacktext">
38            ${apiKey.getLastUsedIP() or 'n/a' if apiKey else _('n/a')}
39        </td>
40    </tr>
41    <tr>
42        <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Last request")}</span></td>
43        <td class="blacktext">
44            ${apiKey.getLastRequest() or 'n/a' if apiKey else _('n/a')}
45        </td>
46    </tr>
47    <tr>
48        <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">${ _("Total uses")}</span></td>
49        <td class="blacktext">
50            ${apiKey.getUseCount() if apiKey else _('n/a')}
51        </td>
52    </tr>
53    % if not apiKey or not apiKey.isBlocked():
54        <tr>
55            <td></td>
56            <td>
57                % if not apiKey:
58                    <form action="${urlHandlers.UHUserAPICreate.getURL(avatar)}" method="POST" onsubmit="return confirm('${_("Please only create an API key if you actually need one. Unused API keys might be deleted after some time.")}');">
59                        <input type="submit" value="Create API key" />
60                    </form>
61                % else:
62                    <form action="${urlHandlers.UHUserAPICreate.getURL(avatar)}" method="POST" onsubmit="return confirm('${_("Warning: When creating a new API key pair, your old key pair will stop working immediately!")}');">
63                        <input type="submit" value="Create a new API key pair" />
64                    </form>
65                % endif
66            </td>
67        </tr>
68    % endif
69
70    % if isAdmin:
71        <tr>
72            <td colspan="2">
73                <div class="groupTitle">${ _("Administration") }</div>
74            </td>
75        </tr>
76        % if apiKey:
77            <tr>
78                <td></td>
79                <td>
80                    <form action="${urlHandlers.UHUserAPIBlock.getURL(avatar)}" method="POST" style="display:inline;">
81                        <input type="submit" value="${_('Unblock API key') if apiKey.isBlocked() else _('Block API key')}" />
82                    </form>
83
84                    <form action="${urlHandlers.UHUserAPIDelete.getURL(avatar)}" method="POST" style="display:inline;" onsubmit="return confirm('${_("Do you really want to DELETE the API key? The user will be able to create a new key, but all history will be lost.")}');">
85                        <input type="submit" value="${_('Delete API key')}" />
86                    </form>
87                </td>
88            </tr>
89            <tr>
90                 <td nowrap class="dataCaptionTD"><span class="dataCaptionFormat">Old keys</span></td>
91                 <td class="blacktext">
92                    % if apiKey.getOldKeys():
93                        <ul>
94                            % for key in apiKey.getOldKeys():
95                                <li>${key}</li>
96                            % endfor
97                        </ul>
98                    % else:
99                        None
100                    % endif
101                 </td>
102             </tr>
103        % else:
104            <tr>
105                <td colspan="2" class="blacktext">
106                    ${_('No actions available')}
107                </td>
108            </tr>
109        % endif
110    % endif
111</table>
Note: See TracBrowser for help on using the repository browser.