Skip to content

Commit 30cf49a

Browse files
markafarrellBryan Havenstein
andauthored
AAP-43751 Reduce default token expiry from 1000 years to 1 year (#710)
--------- Co-authored-by: Bryan Havenstein <[email protected]>
1 parent 9f58e7b commit 30cf49a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ansible_base/lib/dynamic_config/settings_logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def get_mergeable_dab_settings(settings: dict) -> dict: # NOSONAR
265265
if 'oauth2_provider' not in installed_apps:
266266
installed_apps.append('oauth2_provider')
267267

268-
oauth2_provider.setdefault('ACCESS_TOKEN_EXPIRE_SECONDS', 31536000000)
268+
oauth2_provider.setdefault('ACCESS_TOKEN_EXPIRE_SECONDS', 31536000) # 1 year
269269
oauth2_provider.setdefault('AUTHORIZATION_CODE_EXPIRE_SECONDS', 600)
270270
oauth2_provider.setdefault('REFRESH_TOKEN_EXPIRE_SECONDS', 2628000)
271271
# For compat with awx, we don't require PKCE, but the new version

test_app/tests/oauth2_provider/test_authentication.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime, timedelta, timezone
12
from unittest import mock
23

34
import pytest
@@ -50,6 +51,15 @@ def test_oauth2_bearer_get(unauthenticated_api_client, oauth2_admin_access_token
5051
assert response.data['name'] == animal.name
5152

5253

54+
@pytest.mark.django_db
55+
def test_oauth2_token_expiry(oauth2_admin_access_token):
56+
"""
57+
Verify default expiration is 1 year
58+
"""
59+
token = oauth2_admin_access_token[0]
60+
assert token.expires < datetime.now(tz=timezone.utc) + timedelta(weeks=53)
61+
62+
5363
@pytest.mark.parametrize(
5464
'token, expected',
5565
[

0 commit comments

Comments
 (0)