Skip to content

Commit 85864a1

Browse files
authored
Merge pull request #135 from edx/jb/saml-auth-redirect
fix: support for IdP initiated auth on login
2 parents 3f4cf78 + 36938f9 commit 85864a1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

common/djangoapps/third_party_auth/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,10 @@ def get_url_params(self):
803803

804804
def is_active_for_pipeline(self, pipeline):
805805
""" Is this provider being used for the specified pipeline? """
806-
return self.backend_name == pipeline['backend'] and self.slug == pipeline['kwargs']['response']['idp_name']
806+
try:
807+
return self.backend_name == pipeline['backend'] and self.slug == pipeline['kwargs']['response']['idp_name']
808+
except KeyError:
809+
return False
807810

808811
def match_social_auth(self, social_auth):
809812
""" Is this provider being used for this UserSocialAuth entry? """

openedx/core/djangoapps/user_authn/views/login_form.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,15 @@ def login_and_registration_form(request, initial_mode="login"):
197197
saml_provider = False
198198
running_pipeline = pipeline.get(request)
199199
if running_pipeline:
200-
saml_provider, __ = third_party_auth.utils.is_saml_provider(
201-
running_pipeline.get('backend'), running_pipeline.get('kwargs')
202-
)
200+
backend_name = running_pipeline.get('backend')
201+
if backend_name == 'tpa-saml':
202+
# Directly detect SAML backend to avoid registry lookup failures
203+
# (e.g. when pipeline kwargs lack response['idp_name'] at this point).
204+
saml_provider = True
205+
else:
206+
saml_provider, __ = third_party_auth.utils.is_saml_provider(
207+
backend_name, running_pipeline.get('kwargs')
208+
)
203209

204210
enterprise_customer = enterprise_customer_for_request(request)
205211

0 commit comments

Comments
 (0)