From c9ccc1b4a6443c1098762dd6cc35ad3e6927b39d Mon Sep 17 00:00:00 2001 From: Mike Olund Date: Thu, 30 Mar 2017 11:48:13 -0700 Subject: [PATCH] Fixed bug with users who are already logged into IDIR --- edivorce/apps/core/urls.py | 8 -------- edivorce/apps/core/views/main.py | 6 +++++- edivorce/settings/base.py | 2 -- edivorce/settings/openshift.py | 3 ++- setup.py | 28 ---------------------------- 5 files changed, 7 insertions(+), 40 deletions(-) delete mode 100755 setup.py diff --git a/edivorce/apps/core/urls.py b/edivorce/apps/core/urls.py index 32f78043..ac6ab5e1 100644 --- a/edivorce/apps/core/urls.py +++ b/edivorce/apps/core/urls.py @@ -8,10 +8,6 @@ handler500 = 'core.views.main.server_error' urlpatterns = [ # url(r'^guide$', styleguide.guide), url(r'^api/response$', api.UserResponseHandler.as_view()), - - # todo: remove this line once SMGOV headers are working - url(r'^login/headers$', system.headers), - url(r'^login', main.login, name="login"), url(r'^bceid', localdev.bceid, name="bceid"), url(r'^register$', main.register, name="register"), @@ -22,10 +18,6 @@ urlpatterns = [ url(r'^dashboard/(?P.*)', main.dashboard_nav, name="dashboard_nav"), url(r'^health$', system.health), url(r'^legal', main.legal, name="legal"), - - # todo: remove this line once SMGOV headers are working - url(r'^headers$', system.headers), - url(r'^pdf-form(?P[0-9]{1,3}(_we|_claimant1|_claimant2)?)$', pdf.form, name="pdf_form"), url(r'^prequalification/step_(?P[0-9]{2})$', main.prequalification, name="prequalification"), url(r'^question/(?P.*)$', main.question, name="question_steps"), diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py index 02738a3e..214be0b8 100644 --- a/edivorce/apps/core/views/main.py +++ b/edivorce/apps/core/views/main.py @@ -105,7 +105,11 @@ def login(request): guid = request.bceid_user.guid if guid is None: - return render(request, 'localdev/debug.html') + # If a user is logged into an IDIR then they can see the login page + # but the SMGOV headers are missing. If this is the case, then log them out + # of their IDIR, and redirect them back to here again.... + return redirect( + settings.LOGOUT_URL_TEMPLATE % (settings.PROXY_BASE_URL, settings.FORCE_SCRIPT_NAME[:-1] + '/login')) user, created = __get_bceid_user(request) diff --git a/edivorce/settings/base.py b/edivorce/settings/base.py index 3e05da25..a63082b9 100644 --- a/edivorce/settings/base.py +++ b/edivorce/settings/base.py @@ -28,8 +28,6 @@ SECRET_KEY = os.environ.get( DEBUG = False -# TODO: Set ALLOWED_HOSTS this to the actual host headers used by the local/dev/test/prod instances & health probes -# ALLOWED_HOSTS = ['localhost', '127.0.0.1'] ALLOWED_HOSTS = ['*'] # Application definition diff --git a/edivorce/settings/openshift.py b/edivorce/settings/openshift.py index f400882a..4be8679d 100644 --- a/edivorce/settings/openshift.py +++ b/edivorce/settings/openshift.py @@ -73,7 +73,8 @@ WEASYPRINT_CSS_LOOPBACK += PROXY_URL_PREFIX # Integration URLs PROXY_BASE_URL = 'https://justice.gov.bc.ca' -LOGOUT_URL = 'https://logon.gov.bc.ca/clp-cgi/logoff.cgi?returl=%s%s&retnow=1' % (PROXY_BASE_URL, PROXY_URL_PREFIX) +LOGOUT_URL_TEMPLATE = 'https://logon.gov.bc.ca/clp-cgi/logoff.cgi?returl=%s%s&retnow=1' +LOGOUT_URL = LOGOUT_URL_TEMPLATE % (PROXY_BASE_URL, PROXY_URL_PREFIX) # Basic Authentication to prevent anyone from accidentally stumbling across publicly accessible dev/test environments BASICAUTH_ENABLED = os.getenv('BASICAUTH_ENABLED', '').lower() == 'true' diff --git a/setup.py b/setup.py deleted file mode 100755 index eaa93b72..00000000 --- a/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# NOTE: this isn't a real setup.py file. It has been added here -# so additional steps could be injected into the OpenShift/Docker S2I build. -# -# If a file called "setup.py" exists, then the S2I assemble script will run it -# during the build. -# -# TODO: I have added Django-Compressor code to wsgi.py so it runs during deployment -# instead. I'm just keeping the code here until I am sure the other approach -# is working. This script currently does NOTHING - -import os - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "edivorce.settings.openshift") -from django.core.management import execute_from_command_line - -print('') -print('NOTICE: THIS SCRIPT DOES NOT SET UP THE PROJECT!!') -print('If you are trying to set up the project, please run the following command instead:') -print('$ pip install -r requirements.txt') -print('') -print('Executing additional OpenShift S2I assemble tasks defined in setup.py') -print('') - -# Run Django-Compressor offline compression -# print('Running Django Compressor offline compression') -# execute_from_command_line(['manage.py', 'compress'])