mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Merge pull request #1637 from rooftopcellist/exp_setting_update
Token Expiration Setting Update
This commit is contained in:
commit
fd4f78a64c
@ -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 '
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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, exchange='tower_broadcast_all')
|
||||
|
Loading…
Reference in New Issue
Block a user