Skip to content

Commit 6194247

Browse files
authored
Revert "Auto-authorize if valid refresh tokens exist (#754)" (#793)
This reverts commit a1dcd37.
1 parent 324bfcd commit 6194247

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

oauth2_provider/views/base.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ..exceptions import OAuthToolkitError
1616
from ..forms import AllowForm
1717
from ..http import OAuth2ResponseRedirect
18-
from ..models import get_access_token_model, get_application_model, get_refresh_token_model
18+
from ..models import get_access_token_model, get_application_model
1919
from ..scopes import get_scopes_backend
2020
from ..settings import oauth2_settings
2121
from ..signals import app_authorized
@@ -194,12 +194,6 @@ def get(self, request, *args, **kwargs):
194194
expires__gt=timezone.now()
195195
).all()
196196

197-
refresh_tokens = get_refresh_token_model().objects.filter(
198-
user=request.user,
199-
application=kwargs["application"]
200-
).exclude(revoked__lt=timezone.now()).all()
201-
tokens = list(tokens) + [r.access_token for r in refresh_tokens]
202-
203197
# check past authorizations regarded the same scopes as the current one
204198
for token in tokens:
205199
if token.allow_scopes(scopes):

tests/test_authorization_code.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,6 @@ def test_pre_auth_approval_prompt(self):
201201
url = "{url}?{qs}".format(url=reverse("oauth2_provider:authorize"), qs=query_string)
202202
response = self.client.get(url)
203203
self.assertEqual(response.status_code, 302)
204-
# access token expired but valid refresh token exists
205-
tok.expires = timezone.now() - datetime.timedelta(days=1)
206-
tok.save()
207-
reftok = RefreshToken.objects.create(
208-
user=self.test_user, token="0123456789",
209-
application=self.application,
210-
access_token=tok
211-
)
212-
response = self.client.get(url)
213-
self.assertEqual(response.status_code, 302)
214204
# user already authorized the application, but with different scopes: prompt them.
215205
tok.scope = "read"
216206
tok.save()

0 commit comments

Comments
 (0)