From c59c64c91595a7147b094f4bf6b314461b4aa93d Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Fri, 30 Aug 2024 07:13:31 -0600 Subject: [PATCH] Fix SAMLAuth backend to correctly return social auth pipeline results (#15457) --- awx/sso/backends.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/awx/sso/backends.py b/awx/sso/backends.py index bd4cb6c672..572afc3ef0 100644 --- a/awx/sso/backends.py +++ b/awx/sso/backends.py @@ -14,6 +14,7 @@ from django.contrib.auth.models import User from django.conf import settings as django_settings from django.core.signals import setting_changed from django.utils.encoding import force_str +from django.http import HttpResponse # django-auth-ldap from django_auth_ldap.backend import LDAPSettings as BaseLDAPSettings @@ -316,7 +317,13 @@ class SAMLAuth(BaseSAMLAuth): ] ): return None - user = super(SAMLAuth, self).authenticate(request, *args, **kwargs) + pipeline_result = super(SAMLAuth, self).authenticate(request, *args, **kwargs) + + if isinstance(pipeline_result, HttpResponse): + return pipeline_result + else: + user = pipeline_result + # Comes from https://github.com/omab/python-social-auth/blob/v0.2.21/social/backends/base.py#L91 if getattr(user, 'is_new', False): enterprise_auth = _decorate_enterprise_user(user, 'saml')