-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override
LoginView
to provide an SSO button
This change moves our login template override to the `login` app, adds a subclass of Wagtail's `LoginView` to provide extra SSO context, and then adds a "Sign-in with SSO" button if SSO is enabled. This simplifies some of our URLs around SSO (always having /admin/login respond), and moves one of our override templates out of `wagtailadmin_overrides` and justifies its existence a little bit more.
- Loading branch information
1 parent
06f3006
commit ca63940
Showing
6 changed files
with
65 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
"^django-admin/", | ||
"^login", | ||
"^logout", | ||
"^oidc/", | ||
"^password/", | ||
"^tasks/", | ||
] | ||
|
6 changes: 6 additions & 0 deletions
6
...errides/templates/wagtailadmin/login.html → cfgov/login/templates/login/login.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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
{% extends "wagtailadmin/login.html" %} | ||
{% load wagtailadmin_tags %} | ||
|
||
{% block below_login %} | ||
{% if sso_enabled %} | ||
<hr> | ||
<p><a href="{% url 'oidc_authentication_init' %}" class="button" style="text-align: center;">Sign in with Single Sign-On</a></p> | ||
<hr> | ||
{% endif %} | ||
<p>This is a Consumer Financial Protection Bureau (CFPB) information system. The CFPB is an independent agency of the United States Government. CFPB information systems are provided for the processing of official information only. Unauthorized or improper use of this system may result in administrative action, as well as civil and criminal penalties.</p> | ||
<p>Because this is a CFPB information system, you have no reasonable expectation of privacy regarding any communication or data, transiting or stored, on this information system. All data contained in CFPB information systems is owned by the CFPB, and your use of the CFPB information system serves as your consent to your usage being monitored, intercepted, recorded, read, copied, captured, or otherwise audited in any manner by authorized personnel, including, but not limited to, employees, contractors, and/or agents of the United States Government.</p> | ||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.test import TestCase, override_settings | ||
from django.urls import reverse | ||
|
||
|
||
class LoginViewTestCase(TestCase): | ||
|
||
@override_settings(ENABLE_SSO=True) | ||
def test_view_gets_sso_enabled_context(self): | ||
response = self.client.get(reverse("cfgov_login")) | ||
self.assertTrue(response.context["sso_enabled"]) | ||
pass | ||
|
||
@override_settings(ENABLE_SSO=False) | ||
def test_view_gets_sso_disabled_context(self): | ||
response = self.client.get(reverse("cfgov_login")) | ||
self.assertFalse(response.context["sso_enabled"]) |
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,12 @@ | ||
from django.conf import settings | ||
|
||
from wagtail.admin.views.account import LoginView as WagtailLoginView | ||
|
||
|
||
class LoginView(WagtailLoginView): | ||
template_name = "login/login.html" | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super().get_context_data(**kwargs) | ||
context["sso_enabled"] = settings.ENABLE_SSO | ||
return context |