Update URL strucuture, fixed string based calls

This commit is contained in:
Wayne Witzel III
2017-11-09 17:24:04 -05:00
parent 14c5123fda
commit 6d6bbbb627
49 changed files with 1166 additions and 501 deletions

View File

@@ -25,9 +25,9 @@ from radiusauth.backends import RADIUSBackend as BaseRADIUSBackend
import tacacs_plus
# social
from social.backends.saml import OID_USERID
from social.backends.saml import SAMLAuth as BaseSAMLAuth
from social.backends.saml import SAMLIdentityProvider as BaseSAMLIdentityProvider
from social_core.backends.saml import OID_USERID
from social_core.backends.saml import SAMLAuth as BaseSAMLAuth
from social_core.backends.saml import SAMLIdentityProvider as BaseSAMLIdentityProvider
# Ansible Tower
from awx.conf.license import feature_enabled

View File

@@ -13,9 +13,9 @@ from django.shortcuts import redirect
from django.utils.timezone import now
# Python Social Auth
from social.exceptions import SocialAuthBaseException
from social.utils import social_logger
from social.apps.django_app.middleware import SocialAuthExceptionMiddleware
from social_core.exceptions import SocialAuthBaseException
from social_core.utils import social_logger
from social_django.middleware import SocialAuthExceptionMiddleware
# Ansible Tower
from awx.main.models import AuthToken

View File

@@ -1,2 +0,0 @@
# Copyright (c) 2017 Ansible, Inc.
# All Rights Reserved.

View File

@@ -1,27 +0,0 @@
# Copyright (c) 2017 Ansible, Inc.
# All Rights Reserved.
from social.strategies.django_strategy import DjangoStrategy
class AWXDjangoStrategy(DjangoStrategy):
"""A DjangoStrategy for python-social-auth containing
fixes and updates from social-app-django
TODO: Revert back to using the default DjangoStrategy after
we upgrade to social-core / social-app-django. We will also
want to ensure we update the SOCIAL_AUTH_STRATEGY setting.
"""
def request_port(self):
"""Port in use for this request
https://github.com/python-social-auth/social-app-django/blob/master/social_django/strategy.py#L76
"""
try: # django >= 1.9
return self.request.get_port()
except AttributeError: # django < 1.9
host_parts = self.request.get_host().split(':')
try:
return host_parts[1]
except IndexError:
return self.request.META['SERVER_PORT']

View File

@@ -1,13 +1,18 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.
# Django
from django.conf.urls import patterns, url
urlpatterns = patterns(
'awx.sso.views',
url(r'^complete/$', 'sso_complete', name='sso_complete'),
url(r'^error/$', 'sso_error', name='sso_error'),
url(r'^inactive/$', 'sso_inactive', name='sso_inactive'),
url(r'^metadata/saml/$', 'saml_metadata', name='saml_metadata'),
from django.conf.urls import url
from awx.sso.views import (
sso_complete,
sso_error,
sso_inactive,
saml_metadata,
)
urlpatterns = [
url(r'^complete/$', sso_complete, name='sso_complete'),
url(r'^error/$', sso_error, name='sso_error'),
url(r'^inactive/$', sso_inactive, name='sso_inactive'),
url(r'^metadata/saml/$', saml_metadata, name='saml_metadata'),
]

View File

@@ -79,7 +79,7 @@ sso_complete = CompleteView.as_view()
class MetadataView(View):
def get(self, request, *args, **kwargs):
from social.apps.django_app.utils import load_backend, load_strategy
from social_django.utils import load_backend, load_strategy
complete_url = reverse('social:complete', args=('saml', ))
saml_backend = load_backend(
load_strategy(request),