From 1963ab689af0627a38a036604abf681fb23dc1bc Mon Sep 17 00:00:00 2001 From: adamscmRH Date: Tue, 1 May 2018 13:31:00 -0400 Subject: [PATCH] rm an unnecessary uwsgi restart --- awx/api/conf.py | 3 ++- awx/api/serializers.py | 9 ++++----- awx/conf/apps.py | 8 -------- awx/main/tasks.py | 2 -- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/awx/api/conf.py b/awx/api/conf.py index 34bf305f20..58aa9b4cc8 100644 --- a/awx/api/conf.py +++ b/awx/api/conf.py @@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _ # AWX from awx.conf import fields, register from awx.api.fields import OAuth2ProviderField +from oauth2_provider.settings import oauth2_settings register( @@ -36,7 +37,7 @@ register( register( 'OAUTH2_PROVIDER', field_class=OAuth2ProviderField, - default={'ACCESS_TOKEN_EXPIRE_SECONDS': 315360000000, + default={'ACCESS_TOKEN_EXPIRE_SECONDS': oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS, 'AUTHORIZATION_CODE_EXPIRE_SECONDS': 600}, label=_('OAuth 2 Timeout Settings'), help_text=_('Dictionary for customizing OAuth 2 timeouts, available items are ' diff --git a/awx/api/serializers.py b/awx/api/serializers.py index c774898d0d..bc254cb760 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -14,7 +14,6 @@ from datetime import timedelta # OAuth2 from oauthlib.common import generate_token -from oauth2_provider.settings import oauth2_settings # Django from django.conf import settings @@ -1024,7 +1023,7 @@ class UserAuthorizedTokenSerializer(BaseSerializer): validated_data['user'] = current_user validated_data['token'] = generate_token() validated_data['expires'] = now() + timedelta( - seconds=oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS + seconds=settings.OAUTH2_PROVIDER['ACCESS_TOKEN_EXPIRE_SECONDS'] ) obj = super(OAuth2TokenSerializer, self).create(validated_data) obj.save() @@ -1176,7 +1175,7 @@ class OAuth2TokenSerializer(BaseSerializer): validated_data['user'] = current_user validated_data['token'] = generate_token() validated_data['expires'] = now() + timedelta( - seconds=oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS + seconds=settings.OAUTH2_PROVIDER['ACCESS_TOKEN_EXPIRE_SECONDS'] ) obj = super(OAuth2TokenSerializer, self).create(validated_data) if obj.application and obj.application.user: @@ -1239,7 +1238,7 @@ class OAuth2AuthorizedTokenSerializer(BaseSerializer): validated_data['user'] = current_user validated_data['token'] = generate_token() validated_data['expires'] = now() + timedelta( - seconds=oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS + seconds=settings.OAUTH2_PROVIDER['ACCESS_TOKEN_EXPIRE_SECONDS'] ) obj = super(OAuth2AuthorizedTokenSerializer, self).create(validated_data) if obj.application and obj.application.user: @@ -1306,7 +1305,7 @@ class OAuth2PersonalTokenSerializer(BaseSerializer): validated_data['user'] = self.context['request'].user validated_data['token'] = generate_token() validated_data['expires'] = now() + timedelta( - seconds=oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS + seconds=settings.OAUTH2_PROVIDER['ACCESS_TOKEN_EXPIRE_SECONDS'] ) validated_data['application'] = None obj = super(OAuth2PersonalTokenSerializer, self).create(validated_data) diff --git a/awx/conf/apps.py b/awx/conf/apps.py index 06c2facb7a..a70d21326c 100644 --- a/awx/conf/apps.py +++ b/awx/conf/apps.py @@ -11,16 +11,8 @@ class ConfConfig(AppConfig): name = 'awx.conf' verbose_name = _('Configuration') - def configure_oauth2_provider(self, settings): - from oauth2_provider import settings as o_settings - o_settings.oauth2_settings = o_settings.OAuth2ProviderSettings( - settings.OAUTH2_PROVIDER, o_settings.DEFAULTS, - o_settings.IMPORT_STRINGS, o_settings.MANDATORY - ) - def ready(self): self.module.autodiscover() from .settings import SettingsWrapper SettingsWrapper.initialize() configure_external_logger(settings) - self.configure_oauth2_provider(settings) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 31edcc38d7..4f6032b12c 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -204,8 +204,6 @@ def handle_setting_changes(self, setting_keys): if key.startswith('LOG_AGGREGATOR_'): restart_local_services(['uwsgi', 'celery', 'beat', 'callback']) break - elif key == 'OAUTH2_PROVIDER': - restart_local_services(['uwsgi']) @shared_task(bind=True, queue='tower_broadcast_all')