keylist.html 1.93 KB
Newer Older
1
2
{% extends "nm2-base.html" %}
{% load i18n %}
Enrico Zini's avatar
Enrico Zini committed
3
4
5
6
{% load nm %}

{% block content %}

7
<h1><a href="{% url 'api:doc' %}">API</a> keys for {{user.fullname}}</h1>
Enrico Zini's avatar
Enrico Zini committed
8

9
<table class="table table-sm">
Enrico Zini's avatar
Enrico Zini committed
10
11
12
13
14
15
16
17
18
  <thead>
    <tr>
      <th>Name</th><th>Value</th><th>Enabled</th><th>Actions</th>
    </tr>
  </thead>
  <tbody>
  {% for k in keys %}
  <tr>
    <td>{{k.name}}</td>
Romain Porte's avatar
Romain Porte committed
19
    <td><code>{{k.value}}</code></td>
Enrico Zini's avatar
Enrico Zini committed
20
21
    <td>{{k.enabled}}</td>
    <td>
22
      <form class="inline" method="POST" action="{% url 'apikeys:enable' pk=k.pk %}">{% csrf_token %}
Enrico Zini's avatar
Enrico Zini committed
23
24
25
        <input type="hidden" name="enabled" value="{{k.enabled|yesno:"0,1"}}">
        <button>{% if k.enabled %}Disable{% else %}Enable{% endif %}</button>
      </form>
26
      <form class="inline" method="POST" action="{% url 'apikeys:delete' pk=k.pk %}">{% csrf_token %}
Enrico Zini's avatar
Enrico Zini committed
27
28
29
30
31
        <button>Delete</button>
      </form>
    </td>
  </tr>
  {% empty %}
32
  <tr><td colspan="4">No API keys configured for {{user}}</td></tr>
Enrico Zini's avatar
Enrico Zini committed
33
34
35
36
37
38
39
40
41
  {% endfor %}
  </tbody>
  <tfoot>
    <tr>
      <td colspan="4">
        <form action="{{request.get_absolute_uri}}" method="POST">{% csrf_token %}
          {{ form.non_field_errors }}
          {{ form.name.errors }}
          {{ form.name.label_tag }} {{ form.name }}
42
          <button class="btn btn-primary" type="submit">Create</button>
Enrico Zini's avatar
Enrico Zini committed
43
44
45
46
47
48
49
50
        </form>
      </td>
    </tr>
  </tfoot>
</table>

<h2>Use in the last {{audit_log_cutoff_days}} days</h2>

51
<table class="table table-sm">
Enrico Zini's avatar
Enrico Zini committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  <thead>
    <tr>
      <th>When</th>
      <th>Key</th>
      <th>Enabled</th>
      <th>From</th>
      <th>Request</th>
    </tr>
  </thead>
  <tbody>
  {% for l in audit_log %}
  <tr>
    <td>{{l.ts|date:"Y-m-d H:i:s"}}</td>
    <td>{{l.key.name}}</td>
    <td>{{l.key_enabled}}</td>
Romain Porte's avatar
Romain Porte committed
67
68
    <td><code>{{l.remote_addr}}</code></td>
    <td><code>{{l.request_method}} {{l.absolute_uri}}</code></td>
Enrico Zini's avatar
Enrico Zini committed
69
70
  </tr>
  {% empty %}
71
  <tr><td colspan="5">No API key usage for {{user}}</td></tr>
Enrico Zini's avatar
Enrico Zini committed
72
73
74
75
76
  {% endfor %}
  </tbody>
</table>

{% endblock %}