patch session length settings

This commit is contained in:
adamscmRH
2018-06-25 14:39:04 -04:00
parent 380df1b327
commit b5dc3e6b94
6 changed files with 20 additions and 9 deletions

View File

@@ -5,18 +5,20 @@ from django.utils.translation import ugettext_lazy as _
from awx.conf import fields, register
from awx.api.fields import OAuth2ProviderField
from oauth2_provider.settings import oauth2_settings
from django.conf import settings
register(
'SESSION_COOKIE_AGE',
field_class=fields.IntegerField,
'AUTH_TOKEN_EXPIRATION',
field_class=fields.AuthTokenField,
min_value=60,
max_value=30000000000, # approx 1,000 years, higher values give OverflowError
default={'AUTH_TOKEN_EXPIRATION': settings.AUTH_TOKEN_EXPIRATION},
label=_('Idle Time Force Log Out'),
help_text=_('Number of seconds that a user is inactive before they will need to login again.'),
category=_('Authentication'),
category_slug='authentication',
)
register(
'SESSIONS_PER_USER',
field_class=fields.IntegerField,

View File

@@ -6,6 +6,7 @@ from collections import OrderedDict
# Django
from django.core.validators import URLValidator
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
# Django REST Framework
from rest_framework.fields import * # noqa
@@ -42,6 +43,13 @@ class IntegerField(IntegerField):
if ret == '' and self.allow_null and not getattr(self, 'allow_blank', False):
return None
return ret
class AuthTokenField(IntegerField):
def to_internal_value(self, data):
settings.SESSION_COOKIE_AGE = data
return super(AuthTokenField, self).to_internal_value(data)
class StringListField(ListField):

View File

@@ -200,7 +200,8 @@ SESSION_COOKIE_SECURE = True
# Seconds before sessions expire.
# Note: This setting may be overridden by database settings.
SESSION_COOKIE_AGE = 1209600
AUTH_TOKEN_EXPIRATION = 1800
SESSION_COOKIE_AGE = AUTH_TOKEN_EXPIRATION
# Maximum number of per-user valid, concurrent sessions.
# -1 is unlimited

View File

@@ -24,11 +24,11 @@ export default ['i18n', function(i18n) {
MANAGE_ORGANIZATION_AUTH: {
type: 'toggleSwitch',
},
SESSION_COOKIE_AGE: {
AUTH_TOKEN_EXPIRATION: {
type: 'number',
integer: true,
min: 60,
reset: 'SESSION_COOKIE_AGE',
reset: 'AUTH_TOKEN_EXPIRATION',
},
SESSIONS_PER_USER: {
type: 'number',