-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EREGCSC-2448-End-EUA-Session (#1117)
* EREGCSC-2448-End-EUA-Session
- Loading branch information
Showing
12 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
solution/backend/cmcs_regulations/templates/admin/base_site.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends "admin/base_site.html" %} | ||
|
||
{% block extrahead %} | ||
<style> | ||
form#oidc_logout { | ||
display: inline; | ||
margin: 0; | ||
padding: 0; | ||
border: none; | ||
background: none; | ||
border-bottom: 1px solid rgba(255, 255, 255, 0.25); | ||
} | ||
|
||
/* Style the submit button to look like a link */ | ||
form#oidc_logout input[type="submit"] { | ||
cursor: pointer; | ||
border: none; | ||
padding: 0; | ||
font: inherit; | ||
background: none; | ||
} | ||
</style> | ||
{% endblock %} | ||
{% block userlinks %} | ||
<div id="user-tools"> | ||
{% if user.is_active and user.is_staff %} | ||
<a href="/">View site</a> / | ||
{% if request.session.oidc_id_token %} | ||
<!-- OIDC Logout Form --> | ||
<form id="oidc_logout" action="{% url 'oidc_logout' %}" method="post"> | ||
{% csrf_token %} | ||
<input type="submit" value="LOGOUT"> | ||
</form> | ||
{% else %} | ||
<!-- Django Logout Link --> | ||
<a href="{% url 'admin:logout' %}">Logout</a> | ||
{% endif %} | ||
{% else %} | ||
<a href="{% url 'oidc_authentication_init' %}?next={{ request.path }}">Log in</a> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.conf import settings | ||
|
||
|
||
def eua_logout(request): | ||
id_token = request.session.get('oidc_id_token') | ||
# get the domain url from the request and add /login to the end | ||
logout_redirect_url = request.build_absolute_uri('/') + settings.STAGE_ENV + '/logout' | ||
|
||
# In the local environment where there is no STAGE_ENV, handle the possibility of //logout | ||
logout_redirect_url = logout_redirect_url.replace('//logout', '/logout') | ||
|
||
if id_token is not None: | ||
# Use the id_token as needed in the logout request... | ||
logout_request = f'{settings.OIDC_END_EUA_SESSION}?' \ | ||
f'id_token_hint={id_token}&post_logout_redirect_uri={logout_redirect_url}' | ||
return logout_request | ||
else: | ||
# Handle the case where id_token is not available | ||
return "id_token is not available in the user session." |
12 changes: 12 additions & 0 deletions
12
solution/backend/regulations/templates/admin/registration/logged_out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends 'admin/base_site.html' %} | ||
|
||
{% block content %} | ||
<div id="content" class="logout"> | ||
<h2>{% trans 'Logged out' %}</h2> | ||
<p>{% trans "You have successfully logged out." %}</p> | ||
<form action="{% url 'oidc_logout' %}" method="post"> | ||
{% csrf_token %} | ||
<button type="submit">{% trans 'Log Out' %}</button> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,5 @@ | |
})), | ||
])), | ||
path('logout/', auth_views.LogoutView.as_view(), name='logout'), | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters