Skip to content

Commit

Permalink
Better realms navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
np5 committed Oct 30, 2024
1 parent bbe7fc7 commit 886ada4
Show file tree
Hide file tree
Showing 25 changed files with 164 additions and 54 deletions.
2 changes: 1 addition & 1 deletion server/realms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Meta:
("realm", "scim_external_id"),)

def __str__(self):
return self.display_name
return f"{self.realm} / {self.display_name}"

def get_absolute_url(self):
return reverse("realms:group", args=(self.pk,))
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/_realm_group_mappings.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3 class="m-0">Group mapping{{ realm_group_mapping_count|pluralize }} ({{ realm
{% with realm_group_mapping.realm_group as realm_group %}
<td>
{% if perms.realms.view_realmgroup %}
<a href="{{ realm_group.get_absolute_url }}">{{ realm_group }}</a>
<a href="{{ realm_group.get_absolute_url }}">{{ realm_group.display_name }}</a>
{% else %}
{{ realm_group }}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions server/realms/templates/realms/_role_mappings.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ <h3 class="m-0">Role mapping{{ role_mapping_count|pluralize }} ({{ role_mapping_
{% with role_mapping.realm_group as realm_group %}
<td>
{% if perms.realms.view_realmgroup %}
<a href="{{ realm_group.get_absolute_url }}">{{ realm_group }}</a>
<a href="{{ realm_group.get_absolute_url }}">{{ realm_group.display_name }}</a>
{% else %}
{{ realm_group }}
{{ realm_group.display_name }}
{% endif %}
</td>
{% endwith %}
Expand Down
27 changes: 27 additions & 0 deletions server/realms/templates/realms/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends 'base.html' %}
{% load inventory_extras ui_extras %}

{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item active">SSO</li>
</ol>

<h2>Single Sign-On</h2>

{% if perms.realms.view_realm %}
<p><a href="{% url 'realms:list' %}">Realms</a></p>
{% endif %}
{% if perms.realms.view_realmgroup %}
<p><a href="{% url 'realms:groups' %}">Groups</a></p>
{% endif %}
{% if perms.realms.view_realmuser %}
<p><a href="{% url 'realms:users' %}">Users</a></p>
{% endif %}
{% if perms.realms.view_realmgroupmapping %}
<p><a href="{% url 'realms:realm_group_mappings' %}">Group mappings</a></p>
{% endif %}
{% if perms.realms.view_rolemapping %}
<p><a href="{% url 'realms:role_mappings' %}">Role mappings</a></p>
{% endif %}
{% endblock %}
1 change: 1 addition & 0 deletions server/realms/templates/realms/realm_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item active">{{ object }}</li>
</ol>
Expand Down
1 change: 1 addition & 0 deletions server/realms/templates/realms/realm_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
{% if object %}
<li class="breadcrumb-item"><a href="{% url 'realms:view' object.pk %}">{{ object }}</a></li>
Expand Down
1 change: 1 addition & 0 deletions server/realms/templates/realms/realm_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item active">{{ configurations_count }} Realm{{ realms_count|pluralize }}</li>
</ol>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,80 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:view' object.realm.pk %}">{{ object.realm }}</a></li>
<li class="breadcrumb-item active">{{ realm_user }}</li>
</ol>

<h2>Realm user <i>{{ realm_user }}</i></h2>
<h3>Realm user <i>{{ realm_user }}</i></h3>

{% if realm_user.realm.enabled_for_login %}
<h3>Login session expiry</h3>
<h4 class="mt-4 mb-2">Login session expiry</h3>

<dl class="row">
<dt class="col-sm-3 text-md-end">IDP</dt>
<dd class="col-sm-9">{{ object.expires_at|default:"-" }}{% if idp_expiry_age %} — ~{{ idp_expiry_age }} seconds{% endif %}</dd>
<dt class="col-sm-3 text-md-end">User’s session cookie</dt>
<dd class="col-sm-9">
<dl>
<dt>IdP</dt>
<dd>{{ object.expires_at|default:"-" }}{% if idp_expiry_age %} — ~{{ idp_expiry_age }} seconds{% endif %}</dd>
<dt>User’s session cookie</dt>
<dd>
{% if login_session_expire_at_browser_close %}
The user’s session cookie will expire when the user’s Web browser is closed.
{% else %}
{% if object.realm.login_session_expiry %}
{{ computed_expiry }} seconds
{% else %}
same as IDP
same as IdP
{% endif %}
{% endif %}
</dd>
</dl>
{% endif %}

<h3>Orginal claims</h3>
<h4 class="mt-4 mb-2">Orginal claims</h3>

{{ realm_user.claims|pythonprettyprint }}

<h3>Mapped claims</h3>
<h4 class="mt-4 mb-2">Mapped claims</h3>

{% if error %}
<p class="text-danger">{{ error }}</p>
{% endif %}

<dl class="row">
<dt class="col-sm-3 text-md-end">Username</dt>
<dd class="col-sm-9">{{ realm_user.username }}</dd>
<dt class="col-sm-3 text-md-end">Email</dt>
<dd class="col-sm-9">{{ realm_user.email|default:"-" }}</dd>
<dt class="col-sm-3 text-md-end">First name</dt>
<dd class="col-sm-9">{{ realm_user.first_name|default:"-" }}</dd>
<dt class="col-sm-3 text-md-end">Last name</dt>
<dd class="col-sm-9">{{ realm_user.last_name|default:"-" }}</dd>
<dt class="col-sm-3 text-md-end">Full name</dt>
<dd class="col-sm-9">{{ realm_user.full_name|default:"-" }}</dd>
<dt class="col-sm-3 text-md-end">Custom attr. 1</dt>
<dd class="col-sm-9">{{ realm_user.custom_attr_1|default:"-" }}</dd>
<dt class="col-sm-3 text-md-end">Custom attr. 2</dt>
<dd class="col-sm-9">{{ realm_user.custom_attr_2|default:"-" }}</dd>
<dl>
<dt>Username</dt>
<dd>{{ realm_user.username }}</dd>
<dt>Email</dt>
<dd>{{ realm_user.email|default:"-" }}</dd>
<dt>First name</dt>
<dd>{{ realm_user.first_name|default:"-" }}</dd>
<dt>Last name</dt>
<dd>{{ realm_user.last_name|default:"-" }}</dd>
<dt>Full name</dt>
<dd>{{ realm_user.full_name|default:"-" }}</dd>
<dt>Custom attr. 1</dt>
<dd>{{ realm_user.custom_attr_1|default:"-" }}</dd>
<dt>Custom attr. 2</dt>
<dd>{{ realm_user.custom_attr_2|default:"-" }}</dd>
</dl>

<h4 class="mt-4 mb-2">{{ mapped_realm_group_count }} Mapped group{{mapped_realm_group_count|pluralize }}</h3>

{% if mapped_realm_group_count %}
<ul>
{% for realm_group in mapped_realm_groups %}
<li>
{% if perms.realms.view_realmgroup %}
<a href="{{ realm_group.get_absolute_url }}">{{ realm_group.display_name }}</a>
{% else %}
{{ realm_group.display_name }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}

{% if perms.auth.view_group %}
<h3>{{ mapped_group_count }} Mapped group{{ mapped_group_count|pluralize }}</h3>
<h4 class="mt-4 mb-2">{{ mapped_group_count }} Mapped role{{ mapped_group_count|pluralize }}</h3>

{% if mapped_group_count %}
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% with object.realm_group.realm as realm %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:groups' %}">Groups</a></li>
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
<li class="breadcrumb-item active">Update</li>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmgroup_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:groups' %}">Groups</a></li>
<li class="breadcrumb-item active">{{ object }}</li>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmgroup_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:groups' %}">Groups</a></li>
{% if object %}
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
Expand Down
4 changes: 2 additions & 2 deletions server/realms/templates/realms/realmgroup_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
{% for url, anchor_text in breadcrumbs %}
{% if url %}
<li class="breadcrumb-item"><a href="{{ url }}">{{ anchor_text }}</a></li>
Expand Down Expand Up @@ -53,7 +53,7 @@ <h2 class="m-0">Group{{ paginator.count|pluralize }} ({{ paginator.count }})</h2
{{ obj.realm }}
{% endif %}
</td>
<td><a href="{{ obj.get_absolute_url }}">{{ obj }}</a></td>
<td><a href="{{ obj.get_absolute_url }}">{{ obj.display_name }}</a></td>
<td class="text-end py-0">
{% if perms.realms.change_realmgroup and obj.can_be_updated %}
{% url 'realms:update_group' obj.pk as url %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% with object.realm_group.realm as realm %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:realm_group_mappings' %}">Group mappings</a></li>
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
<li class="breadcrumb-item active">Delete</li>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmgroupmapping_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:realm_group_mappings' %}">Group mappings</a></li>
{% if object %}
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmgroupmapping_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item active">Group mapping{{ realm_group_mappings_count|pluralize }} ({{ realm_group_mapping_count }})</li>
</ol>

Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmuser_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:users' %}">Users</a></li>
<li class="breadcrumb-item active">{{ object }}</li>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/realmuser_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
{% for url, anchor_text in breadcrumbs %}
{% if url %}
<li class="breadcrumb-item"><a href="{{ url }}">{{ anchor_text }}</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% with object.realm as realm %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:role_mappings' %}">Role mappings</a></li>
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
<li class="breadcrumb-item active">Delete</li>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/rolemapping_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:role_mappings' %}">Role mappings</a></li>
{% if object %}
<li class="breadcrumb-item"><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
Expand Down
2 changes: 1 addition & 1 deletion server/realms/templates/realms/rolemapping_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:list' %}">Realms</a></li>
<li class="breadcrumb-item"><a href="{% url 'realms:index' %}">SSO</a></li>
<li class="breadcrumb-item active">Role mapping{{ role_mappings_count|pluralize }} ({{ role_mapping_count }})</li>
</ol>

Expand Down
10 changes: 6 additions & 4 deletions server/realms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

app_name = "realms"
urlpatterns = [
path('', views.RealmListView.as_view(), name='list'),
# index
path('', views.IndexView.as_view(), name='index'),

# users
path('users/', views.RealmUserListView.as_view(), name='users'),
Expand Down Expand Up @@ -46,9 +47,10 @@
name='delete_role_mapping'),

# realms
path('<slug:backend>/create/', views.CreateRealmView.as_view(), name='create'),
path('<uuid:pk>/', views.RealmView.as_view(), name='view'),
path('<uuid:pk>/update/', views.UpdateRealmView.as_view(), name='update'),
path('realms/', views.RealmListView.as_view(), name='list'),
path('realms/<slug:backend>/create/', views.CreateRealmView.as_view(), name='create'),
path('realms/<uuid:pk>/', views.RealmView.as_view(), name='view'),
path('realms/<uuid:pk>/update/', views.UpdateRealmView.as_view(), name='update'),

# SSO test views
path('<uuid:pk>/test/', views.TestRealmView.as_view(), name='test'),
Expand Down
Loading

0 comments on commit 886ada4

Please sign in to comment.