Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mattia Rizzolo
nm.debian.org
Commits
29b942ce
Commit
29b942ce
authored
Apr 20, 2020
by
Enrico Zini
Browse files
Added page to see a person's identities. refs:
#2
parent
4f809504
Changes
5
Hide whitespace changes
Inline
Side-by-side
signon/templates/signon/audit_identities.html
0 → 100644
View file @
29b942ce
{% load i18n %}
{% for identity in identities %}
<div
class=
"card mt-4"
>
<div
class=
"card-header"
>
{% with identity.get_provider as provider %}
{% if identity.profile %}
<a
href=
"{{identity.profile}}"
>
{% endif %}
{% if provider.icon %}
<img
style=
"vertical-align: text-top; height: 1em"
class=
"mr-2"
src=
"{{STATIC_URL}}{{provider.icon}}"
></img>
{% else %}
<span
class=
"mr-2 fa fa-sign-in"
></span>
{% endif %}
{{provider.label}}:
{{identity.fullname}}
<
{{identity.username}}
>
{% endwith %}
{% if identity.profile %}
</a>
{% endif %}
</div>
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
{% if identity.picture %}
<img
class=
"personpic ml-auto"
src=
"{{identity.picture}}"
></img>
{% endif %}
{% trans "Account information" %}
</h5>
<table
class=
"table table-sm"
>
<tr><th>
{% trans "Last used" %}
</th><td>
{{identity.last_used|date:"Y-m-d"}}
</td></tr>
{% if identity.subject %}
<tr><th>
{% trans "Subject" %}
</th><td>
{{identity.subject}}
</td></tr>
{% endif %}
{% if identity.fullname %}
<tr><th>
{% trans "Full name" %}
</th><td>
{{identity.fullname}}
</td></tr>
{% endif %}
{% if identity.username %}
<tr><th>
{% trans "User name" %}
</th><td>
{{identity.username}}
</td></tr>
{% endif %}
</table>
<h5
class=
"card-title"
>
{% trans "Audit log" %}
</h5>
<table
class=
"table table-sm"
>
<thead>
<tr>
<th>
{% trans "Date" %}
</th>
<th>
{% trans "Author" %}
</th>
<th>
{% trans "Notes" %}
</th>
<th>
{% trans "Changes" %}
</th>
</tr>
</thead>
<tbody>
{% for e in identity.audit_log.all %}
<tr>
<td>
{{e.logdate|date:"Y-m-d H:i:s"}}
</td>
<td><a
href=
"{{e.author.get_absolute_url}}"
>
{{e.author}}
</a></td>
<td>
{{e.notes}}
</td>
<td>
<ul>
{% for field, old, new in e.get_changes_list %}
<li>
{{field}}: {{old}} → {{new}}
</li>
{% endfor %}
</ul>
</td>
</tr>
{% empty %}
<tr><td
colspan=
"4"
class=
"text-center"
><i>
{% trans "No audit log for this identity" %}
</i></td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
signon/templates/signon/identities.html
0 → 100644
View file @
29b942ce
{% extends "nm2-base.html" %}
{% load nm %}
{% load i18n %}
{% block content %}
<h1>
{{person.fullname}} identities
</h1>
{% if identities %}
{% include "signon/audit_identities.html" with identities=identities only %}
{% endif %}
{% endblock %}
signon/templates/signon/login.html
View file @
29b942ce
...
...
@@ -23,19 +23,21 @@
{% for provider in providers_active %}
<li
class=
"row"
>
<div
class=
"btn btn-info btn-lg disabled col-sm-6"
>
{% with provider.get_active_identity as identity %}
{% if provider.icon %}
<img
style=
"vertical-align: text-top; height: 1em"
class=
"mr-2"
src=
"{{STATIC_URL}}{{provider.icon}}"
></img>
{% else %}
<span
class=
"mr-2 fa fa-sign-in"
></span>
{% endif %}
{% if
provider
.profile %}
<a
href=
"{{
provider
.profile}}"
>
{{provider.label}}
</a>
{% if
identity
.profile %}
<a
href=
"{{
identity
.profile}}"
>
{{provider.label}}
</a>
{% else %}
{{provider.label}}
{% endif %}
{% if
provider
.username %}
({{
provider
.username}})
{% if
identity
.username %}
({{
identity
.username}})
{% endif %}
{% endwith %}
</div>
<div
class=
"btn btn-light btn-lg disabled col-sm-6"
>
{% if provider.get_active_identity %}
...
...
@@ -81,52 +83,8 @@
{% endif %}
{% if identities %}
<h2>
Identity audit logs
</h2>
{% for identity in identities %}
<div
class=
"card mt-4"
>
<div
class=
"card-header"
>
{% with identity.get_provider as provider %}
{% if identity.profile %}
<a
href=
"{{identity.profile}}"
>
{% endif %}
{% if provider.icon %}
<img
style=
"vertical-align: text-top; height: 1em"
class=
"mr-2"
src=
"{{STATIC_URL}}{{provider.icon}}"
></img>
{% else %}
<span
class=
"mr-2 fa fa-sign-in"
></span>
{% endif %}
{{provider.label}}:
{{identity.fullname}}
<
{{identity.username}}
>
{% endwith %}
{% if identity.profile %}
</a>
{% endif %}
</div>
<table
id=
"audit_log"
class=
"table table-sm card-body mb-0"
>
<thead>
<tr>
<th>
{% trans "Date" %}
</th>
<th>
{% trans "Author" %}
</th>
<th>
{% trans "Notes" %}
</th>
<th>
{% trans "Changes" %}
</th>
</tr>
</thead>
<tbody>
{% for e in identity.audit_log.all %}
<tr>
<td>
{{e.logdate|date:"Y-m-d H:i:s"}}
</td>
<td><a
href=
"{{e.author.get_absolute_url}}"
>
{{e.author}}
</a></td>
<td>
{{e.notes}}
</td>
<td>
<ul>
{% for field, old, new in e.get_changes_list %}
<li>
{{field}}: {{old}} → {{new}}
</li>
{% endfor %}
</ul>
</td>
</tr>
{% empty %}
<tr><td
colspan=
"4"
class=
"text-center"
><i>
{% trans "No audit log for this identity" %}
</i></td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
<h2>
{% trans "Identity audit logs" %}
</h2>
{% include "signon/audit_identities.html" with identities=identities only %}
{% endif %}
{% endblock %}
signon/urls.py
View file @
29b942ce
...
...
@@ -3,6 +3,8 @@ from . import views
urlpatterns
=
[
path
(
'login/'
,
views
.
Login
.
as_view
(),
name
=
'signon_login'
),
path
(
'identities/'
,
views
.
Identities
.
as_view
(),
name
=
'signon_identities'
),
path
(
'identities/<key>/'
,
views
.
Identities
.
as_view
(),
name
=
'signon_identities_person'
),
path
(
'logout/'
,
views
.
Logout
.
as_view
(),
name
=
'signon_logout'
),
path
(
'oidc/callback/<name>/'
,
views
.
OIDCAuthenticationCallbackView
.
as_view
(),
name
=
'signon_oidc_callback'
),
]
signon/views.py
View file @
29b942ce
...
...
@@ -4,7 +4,7 @@ from django.views.generic import View, TemplateView
from
django
import
http
from
django.shortcuts
import
redirect
from
django.contrib
import
auth
from
backend.mixins
import
VisitorMixin
from
backend.mixins
import
VisitorMixin
,
VisitPersonMixin
from
backend.models
import
Person
from
.models
import
Identity
from
.
import
providers
...
...
@@ -45,6 +45,16 @@ class Logout(View):
return
redirect
(
"home"
)
class
Identities
(
VisitPersonMixin
,
TemplateView
):
template_name
=
"signon/identities.html"
require_visit_perms
=
"view_person_audit_log"
def
get_context_data
(
self
,
**
kw
):
ctx
=
super
().
get_context_data
(
**
kw
)
ctx
[
"identities"
]
=
self
.
person
.
identities
.
all
()
return
ctx
class
OIDCAuthenticationCallbackView
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kw
):
name
=
self
.
kwargs
[
"name"
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment