From 3a34630e85dbdc67556247ec0a695b9de6171f5b Mon Sep 17 00:00:00 2001 From: Shaun Kruger Date: Mon, 16 Mar 2015 14:58:26 -0600 Subject: [PATCH] Remove vestigial feature whose tests were causing unit tests to fail. --- docs/api.rst | 8 -------- provider/constants.py | 1 - provider/oauth2/tests.py | 27 --------------------------- provider/views.py | 22 ++++++++-------------- 4 files changed, 8 insertions(+), 50 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 3d10d5e4..46696669 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -62,14 +62,6 @@ Session key prefix to store temporary data while the user is completing the authentication / authorization process. -.. attribute:: SINGLE_ACCESS_TOKEN - - :settings: `OAUTH_SINGLE_ACCESS_TOKEN` - :default: `False` - - To have the provider only create and retrieve one access token per - user/client/scope combination, set to `True`. - `provider.forms` ---------------- .. automodule:: provider.forms diff --git a/provider/constants.py b/provider/constants.py index 7f94b8e5..b98c285d 100644 --- a/provider/constants.py +++ b/provider/constants.py @@ -40,4 +40,3 @@ SESSION_KEY = getattr(settings, 'OAUTH_SESSION_KEY', 'oauth') -SINGLE_ACCESS_TOKEN = getattr(settings, 'OAUTH_SINGLE_ACCESS_TOKEN', False) diff --git a/provider/oauth2/tests.py b/provider/oauth2/tests.py index e06412c2..1aef946a 100644 --- a/provider/oauth2/tests.py +++ b/provider/oauth2/tests.py @@ -287,33 +287,6 @@ def test_fetching_access_token_with_invalid_grant_type(self): self.assertEqual('unsupported_grant_type', json.loads(response.content)['error'], response.content) - def test_fetching_single_access_token(self): - constants.SINGLE_ACCESS_TOKEN = True - - result1 = self._login_authorize_get_token() - result2 = self._login_authorize_get_token() - - self.assertEqual(result1['access_token'], result2['access_token']) - - constants.SINGLE_ACCESS_TOKEN = False - - def test_fetching_single_access_token_after_refresh(self): - constants.SINGLE_ACCESS_TOKEN = True - - token = self._login_authorize_get_token() - - self.client.post(self.access_token_url(), { - 'grant_type': 'refresh_token', - 'refresh_token': token['refresh_token'], - 'client_id': self.get_client().client_id, - 'client_secret': self.get_client().client_secret, - }) - - new_token = self._login_authorize_get_token() - self.assertNotEqual(token['access_token'], new_token['access_token']) - - constants.SINGLE_ACCESS_TOKEN = False - def test_fetching_access_token_multiple_times(self): self._login_authorize_get_token() code = self.get_grant().code diff --git a/provider/views.py b/provider/views.py index 0bd9b2cf..20a95f97 100644 --- a/provider/views.py +++ b/provider/views.py @@ -513,13 +513,10 @@ def authorization_code(self, request, data, client): """ grant = self.get_authorization_code_grant(request, request.POST, client) - if constants.SINGLE_ACCESS_TOKEN: - at = self.get_access_token(request, grant.user, grant.scope.all(), client) - else: - at = self.create_access_token(request, grant.user, - list(grant.scope.all()), client) - rt = self.create_refresh_token(request, grant.user, - list(grant.scope.all()), at, client) + at = self.create_access_token(request, grant.user, + list(grant.scope.all()), client) + rt = self.create_refresh_token(request, grant.user, + list(grant.scope.all()), at, client) self.invalidate_grant(grant) @@ -554,13 +551,10 @@ def password(self, request, data, client): user = data.get('user') scope = data.get('scope') - if constants.SINGLE_ACCESS_TOKEN: - at = self.get_access_token(request, user, scope, client) - else: - at = self.create_access_token(request, user, scope, client) - # Public clients don't get refresh tokens - if client.client_type != 1: - rt = self.create_refresh_token(request, user, scope, at, client) + at = self.create_access_token(request, user, scope, client) + # Public clients don't get refresh tokens + if client.client_type != 1: + rt = self.create_refresh_token(request, user, scope, at, client) return self.access_token_response(at)