Skip to content
Snippets Groups Projects
Commit 992c38a3 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Handle multiple cases of an attribute in Shibboleth session

Due to the fact that we are using multiple attribute authorities,
there are some cases (specifically email) where there are multiple
values provides for an attribute, separated by a semi-colon.

This update handles those instances and takes the first value in
the list.
parent 8eaf6f19
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ class ShibbolethRemoteUserBackend(backends.RemoteUserBackend):
create_unknown_user = True
attribute_map = getattr(settings, 'SHIB_ATTRIBUTE_MAP',
DEFAULT_SHIB_ATTRIBUTES)
attribute_delimiter = ';'
def authenticate(self, request, remote_user):
......@@ -93,6 +94,8 @@ class ShibbolethRemoteUserBackend(backends.RemoteUserBackend):
for user_attr, header in cls.attribute_map.items():
value = request.META.get(header, None)
if value:
# Check if there are multiple entries; if so, take the first
value = value.split(cls.attribute_delimiter)[0]
shib_user_attr[user_attr] = value
# Update user with attributes from the shib session only if there are
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment