From b21687d5119ea1519abdaf8967e3a9391661f4ec Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 10:58:55 -0500 Subject: [PATCH 01/10] Add django-shibboleth-remoteuser. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 84c9dd9..e892922 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,6 @@ Django==1.8.3 django-angular==0.7.15 django-bootstrap3==6.1.0 django-bootstrap3-datetimepicker==2.2.3 +django-shibboleth-remoteuser==0.5 requests==2.7.0 wheel==0.24.0 From d99c2b603052970c7a744a3ea2702947451bd924 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 11:00:35 -0500 Subject: [PATCH 02/10] Add static gitignore requiring collectstatic. --- static/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 static/.gitignore diff --git a/static/.gitignore b/static/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/static/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file From 7c994dc562a953520616c91482a4771d782025f7 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 11:04:00 -0500 Subject: [PATCH 03/10] Add settings.py configs for django-shibboleth. --- clintools/settings.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clintools/settings.py b/clintools/settings.py index 9192c87..cc6f602 100644 --- a/clintools/settings.py +++ b/clintools/settings.py @@ -54,6 +54,11 @@ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', + 'shibboleth.middleware.ShibbolethRemoteUserMiddleware', +) + +AUTHENTICATION_BACKENDS += ( + 'shibboleth.backends.ShibbolethRemoteUserBackend', ) ROOT_URLCONF = 'clintools.urls' @@ -76,6 +81,14 @@ WSGI_APPLICATION = 'clintools.wsgi.application' +SHIBBOLETH_ATTRIBUTE_MAP = { + "shib-user": (True, "username"), + "shib-given-name": (False, "first_name"), + "shib-sn": (False, "last_name"), + "shib-mail": (False, "email"), +} + +LOGIN_URL = 'https://pttrack.snhc.wustl.edu/Shibboleth.sso/Login' # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases From 634eef6feabf7f6755ea95d7919636c746f2b863 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 11:06:53 -0500 Subject: [PATCH 04/10] Fix error in settings.py and update reset_db to collecstatic. --- clintools/settings.py | 4 ++-- reset_db.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clintools/settings.py b/clintools/settings.py index cc6f602..6ef3545 100644 --- a/clintools/settings.py +++ b/clintools/settings.py @@ -57,9 +57,9 @@ 'shibboleth.middleware.ShibbolethRemoteUserMiddleware', ) -AUTHENTICATION_BACKENDS += ( +AUTHENTICATION_BACKENDS = [ 'shibboleth.backends.ShibbolethRemoteUserBackend', -) +] ROOT_URLCONF = 'clintools.urls' diff --git a/reset_db.sh b/reset_db.sh index 6bcff7d..ae97e23 100644 --- a/reset_db.sh +++ b/reset_db.sh @@ -1,3 +1,4 @@ rm db.sqlite3 rm pttrack/migrations/000*py +python manage.py collectstatic python manage.py makemigrations pttrack && python manage.py migrate && python manage.py shell < init_db.py From c96928193003e84fc058ebd8675c9e6a8766d171 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 11:18:56 -0500 Subject: [PATCH 05/10] update settings to use absolute paths. --- clintools/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clintools/settings.py b/clintools/settings.py index 6ef3545..35c23aa 100644 --- a/clintools/settings.py +++ b/clintools/settings.py @@ -20,7 +20,7 @@ # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -with open('secrets/secret_key.txt') as f: +with open(os.path.join(BASE_DIR, 'secrets/secret_key.txt')) as f: SECRET_KEY = f.read().strip() From d5385eda4960ec1b6cb3278b5a5cd506d88fe401 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 11 Jul 2015 11:31:20 -0500 Subject: [PATCH 06/10] Update urls to redirect on index request. --- clintools/urls.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clintools/urls.py b/clintools/urls.py index bc2b723..9b225ff 100644 --- a/clintools/urls.py +++ b/clintools/urls.py @@ -1,5 +1,6 @@ from django.conf.urls import include, url from django.contrib import admin +from django.views.generic.base import RedirectView urlpatterns = [ # Examples: @@ -7,4 +8,5 @@ # url(r'^blog/', include('blog.urls')), url(r'^pttrack/', include('pttrack.urls')), url(r'^admin/', include(admin.site.urls)), + url(r'^$', RedirectView.as_view(pattern_name="home", permanent=False)), ] From 4657402ca57a5f66b93ff06dd1a4730877998a83 Mon Sep 17 00:00:00 2001 From: washu Date: Sun, 12 Jul 2015 00:31:32 -0500 Subject: [PATCH 07/10] Update requiremetnts.txt to correctly download brown's django-sibboleth stuff. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e892922..ed29007 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ Django==1.8.3 django-angular==0.7.15 django-bootstrap3==6.1.0 django-bootstrap3-datetimepicker==2.2.3 -django-shibboleth-remoteuser==0.5 +-e git+https://github.com/Brown-University-Library/django-shibboleth-remoteuser.git@ee4abe32681d1f4caa17e6ee897f32985f1e6c33#egg=django-shibboleth-remoteuser requests==2.7.0 wheel==0.24.0 From 9d876a3db2b0cca4cdd8c9b531f345140d95c354 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Wed, 15 Jul 2015 17:12:34 -0500 Subject: [PATCH 08/10] Add recommended debugging stuff for shibboleth app. --- clintools/settings.py | 1 + clintools/urls.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/clintools/settings.py b/clintools/settings.py index 35c23aa..6c59640 100644 --- a/clintools/settings.py +++ b/clintools/settings.py @@ -43,6 +43,7 @@ 'bootstrap3', 'bootstrap3_datetime', 'djangular', + 'shibboleth', ) MIDDLEWARE_CLASSES = ( diff --git a/clintools/urls.py b/clintools/urls.py index 4014c92..ae957b7 100644 --- a/clintools/urls.py +++ b/clintools/urls.py @@ -8,6 +8,6 @@ # url(r'^blog/', include('blog.urls')), url(r'^pttrack/', include('pttrack.urls')), url(r'^admin/', include(admin.site.urls)), - url(r'^accounts/', include('django.contrib.auth.urls')), url(r'^$', RedirectView.as_view(pattern_name="home", permanent=False)), + url(r'^shib/', include('shibboleth.urls', namespace='shibboleth')), ] From c41946ddac5b741f5e251a3f002987427948d401 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 18 Jul 2015 14:48:44 -0500 Subject: [PATCH 09/10] Get Shibboleth-based auth up and working. --- clintools/settings.py | 9 +++++---- pttrack/templates/pttrack/base.html | 4 ++-- pttrack/templates/pttrack/role-choice.html | 6 +++--- pttrack/views.py | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/clintools/settings.py b/clintools/settings.py index 6c59640..8ef6069 100644 --- a/clintools/settings.py +++ b/clintools/settings.py @@ -83,10 +83,11 @@ WSGI_APPLICATION = 'clintools.wsgi.application' SHIBBOLETH_ATTRIBUTE_MAP = { - "shib-user": (True, "username"), - "shib-given-name": (False, "first_name"), - "shib-sn": (False, "last_name"), - "shib-mail": (False, "email"), + "wustlEduId": (True, "wustl-pk"), +# "cn": (False, "first_name"), + "givenName": (False, "first_name"), + "sn": (False, "last_name"), +# "mail": (False, "email"), } LOGIN_URL = 'https://pttrack.snhc.wustl.edu/Shibboleth.sso/Login' diff --git a/pttrack/templates/pttrack/base.html b/pttrack/templates/pttrack/base.html index 68d93a4..f5c42f1 100644 --- a/pttrack/templates/pttrack/base.html +++ b/pttrack/templates/pttrack/base.html @@ -40,7 +40,7 @@ {% if user.is_authenticated %} @@ -63,4 +63,4 @@ - \ No newline at end of file + diff --git a/pttrack/templates/pttrack/role-choice.html b/pttrack/templates/pttrack/role-choice.html index cddacca..f5ea24e 100644 --- a/pttrack/templates/pttrack/role-choice.html +++ b/pttrack/templates/pttrack/role-choice.html @@ -7,8 +7,8 @@ {% endblock %} {% block header %} -

Choose a role

-

You're listed as performing more than one role here. What are you doing today?

+

How are you volunteering?

+

It looks to us like you wear a couple of different hats around here. What are you doing today?

{% endblock %} {% block content %} @@ -41,4 +41,4 @@

Choose a role

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/pttrack/views.py b/pttrack/views.py index c749dfa..1612279 100644 --- a/pttrack/views.py +++ b/pttrack/views.py @@ -70,9 +70,9 @@ class ProviderCreate(FormView): form_class = myforms.ProviderForm def get_initial(self): + return {'first_name': self.request.user.first_name, - 'last_name': self.request.user.last_name, - 'middle_name': self.request.user.last_name} + 'last_name': self.request.user.last_name} def form_valid(self, form): provider = form.save(commit=False) From dc1f59adb8f480b15b688482e04e00faba060017 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sat, 18 Jul 2015 15:48:11 -0500 Subject: [PATCH 10/10] Debug views to shibboleth. --- pttrack/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pttrack/views.py b/pttrack/views.py index 1612279..d41a980 100644 --- a/pttrack/views.py +++ b/pttrack/views.py @@ -300,10 +300,13 @@ def choose_clintype(request): RADIO_CHOICE_KEY = 'radio-roles' if request.POST: + print "POST", request.session.items() request.session['clintype_pk'] = request.POST[RADIO_CHOICE_KEY] + print "POST", request.session.items() return HttpResponseRedirect(request.GET['next']) if request.GET: + print "GET", request.session.items() role_options = request.user.provider.clinical_roles.all() if len(role_options) == 1: