Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Shibboleth #7

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions clintools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'bootstrap3',
'bootstrap3_datetime',
'djangular',
'shibboleth',
)

MIDDLEWARE_CLASSES = (
Expand All @@ -54,8 +55,13 @@
'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'

TEMPLATES = [
Expand All @@ -76,6 +82,16 @@

WSGI_APPLICATION = 'clintools.wsgi.application'

SHIBBOLETH_ATTRIBUTE_MAP = {
"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'

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

Expand Down
2 changes: 1 addition & 1 deletion clintools/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
]
4 changes: 2 additions & 2 deletions pttrack/templates/pttrack/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ul>
{% if user.is_authenticated %}
<ul class="nav navbar-nav pull-right">
<li><a href="{% url 'logout' %}">Logout
<li><a href="{% url 'shibboleth:logout' %}">Logout
{{ request.user.provider.name }} acting as {{ request.session.clintype_pk | default:"[no role]" }}
</a></li>
</ul>
Expand All @@ -63,4 +63,4 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js"></script>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions pttrack/templates/pttrack/role-choice.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{% endblock %}

{% block header %}
<h1>Choose a role</h1>
<p class="lead">You're listed as performing more than one role here. What are you doing today?</p>
<h2>How are you volunteering?</h2>
<p class="lead">It looks to us like you wear a couple of different hats around here. What are you doing today?</p>
{% endblock %}

{% block content %}
Expand Down Expand Up @@ -41,4 +41,4 @@ <h1>Choose a role</h1>

</div>

{% endblock %}
{% endblock %}
7 changes: 5 additions & 2 deletions pttrack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Django==1.8.3
django-angular==0.7.15
django-bootstrap3==6.1.0
django-bootstrap3-datetimepicker==2.2.3
-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
1 change: 1 addition & 0 deletions reset_db.sh
Original file line number Diff line number Diff line change
@@ -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