mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 02:31:03 -03:30
update social auth strategy to have fixes from social-app-django
This commit is contained in:
@@ -491,7 +491,7 @@ else:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Social Auth configuration.
|
# Social Auth configuration.
|
||||||
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
|
SOCIAL_AUTH_STRATEGY = 'awx.sso.strategies.django_strategy.AWXDjangoStrategy'
|
||||||
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
|
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
|
||||||
SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL # noqa
|
SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL # noqa
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
SOCIAL_AUTH_PIPELINE = (
|
||||||
|
|||||||
2
awx/sso/strategies/__init__.py
Normal file
2
awx/sso/strategies/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Copyright (c) 2017 Ansible, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
26
awx/sso/strategies/django_strategy.py
Normal file
26
awx/sso/strategies/django_strategy.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# 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
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, storage, request=None, tpl=None):
|
||||||
|
super(AWXDjangoStrategy, self).__init__(storage, tpl)
|
||||||
|
|
||||||
|
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']
|
||||||
Reference in New Issue
Block a user