Skip to content

Commit 5c2c6a2

Browse files
committed
Fixed issue #424
1 parent 118f209 commit 5c2c6a2

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

oauth2_provider/oauth2_validators.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ def save_authorization_code(self, client_id, code, request, *args, **kwargs):
297297
scope=' '.join(request.scopes))
298298
g.save()
299299

300+
def rotate_refresh_token(self, request):
301+
"""
302+
"""
303+
return oauth2_settings.ROTATE_REFRESH_TOKEN
304+
300305
@transaction.atomic
301306
def save_bearer_token(self, token, request, *args, **kwargs):
302307
"""

oauth2_provider/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'AUTHORIZATION_CODE_EXPIRE_SECONDS': 60,
4444
'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
4545
'REFRESH_TOKEN_EXPIRE_SECONDS': None,
46+
'ROTATE_REFRESH_TOKEN': True,
4647
'APPLICATION_MODEL': getattr(settings, 'OAUTH2_PROVIDER_APPLICATION_MODEL', 'oauth2_provider.Application'),
4748
'REQUEST_APPROVAL_PROMPT': 'force',
4849
'ALLOWED_REDIRECT_URI_SCHEMES': ['http', 'https'],
@@ -154,5 +155,4 @@ def validate_setting(self, attr, val):
154155
if not val and attr in self.mandatory:
155156
raise AttributeError("OAuth2Provider setting: '%s' is mandatory" % attr)
156157

157-
158158
oauth2_settings = OAuth2ProviderSettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS, MANDATORY)

oauth2_provider/tests/test_authorization_code.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,14 @@ def test_refresh_repeating_requests_non_rotating_tokens(self):
707707
'refresh_token': content['refresh_token'],
708708
'scope': content['scope'],
709709
}
710+
oauth2_settings.ROTATE_REFRESH_TOKEN = False
710711

711-
with mock.patch('oauthlib.oauth2.rfc6749.request_validator.RequestValidator.rotate_refresh_token',
712-
return_value=False):
713-
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
714-
self.assertEqual(response.status_code, 200)
715-
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
716-
self.assertEqual(response.status_code, 200)
712+
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
713+
self.assertEqual(response.status_code, 200)
714+
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
715+
self.assertEqual(response.status_code, 200)
716+
717+
oauth2_settings.ROTATE_REFRESH_TOKEN = True
717718

718719
def test_basic_auth_bad_authcode(self):
719720
"""

0 commit comments

Comments
 (0)