Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionalize external_login_or_signup shib behavior on existence of apache shib vars #507

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions common/djangoapps/external_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def external_login_or_signup(request,
log.info(u"External_Auth login_or_signup for %s : %s : %s : %s", external_domain, external_id, email, fullname)
internal_user = eamap.user
if internal_user is None:
if settings.MITX_FEATURES.get('AUTH_USE_SHIB'):
if settings.MITX_FEATURES.get('AUTH_USE_SHIB') and 'shib:' in external_domain[0:5]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd use external_domain.startswith('shib:'). @brianhw can you make that change to this PR, since @jbau is on vacation?

# if we are using shib, try to link accounts using email
try:
link_user = User.objects.get(email=eamap.external_email)
Expand All @@ -175,7 +175,7 @@ def external_login_or_signup(request,
return signup(request, eamap)

# We trust shib's authentication, so no need to authenticate using the password again
if settings.MITX_FEATURES.get('AUTH_USE_SHIB'):
if settings.MITX_FEATURES.get('AUTH_USE_SHIB') and 'shib:' in external_domain[0:5]:
uname = internal_user.username
user = internal_user
# Assuming this 'AUTHENTICATION_BACKENDS' is set in settings, which I think is safe
Expand Down Expand Up @@ -204,7 +204,7 @@ def external_login_or_signup(request,
# Now to try enrollment
# Need to special case Shibboleth here because it logs in via a GET.
# testing request.method for extra paranoia
if settings.MITX_FEATURES.get('AUTH_USE_SHIB') and 'shib:' in external_domain and request.method == 'GET':
if settings.MITX_FEATURES.get('AUTH_USE_SHIB') and 'shib:' in external_domain[0:5] and request.method == 'GET':
enroll_request = make_shib_enrollment_request(request)
student_views.try_change_enrollment(enroll_request)
else:
Expand Down