@@ -265,10 +265,19 @@ def validate_logout_request(request, id_token_hint, client_id, post_logout_redir
265
265
class RPInitiatedLogoutView (OIDCLogoutOnlyMixin , FormView ):
266
266
template_name = "oauth2_provider/logout_confirm.html"
267
267
form_class = ConfirmLogoutForm
268
- token_types_to_delete = [
268
+ # Only delete tokens for Application whose client type and authorization
269
+ # grant type are in the respective lists.
270
+ token_deletion_client_types = [
269
271
Application .CLIENT_PUBLIC ,
270
272
Application .CLIENT_CONFIDENTIAL ,
271
273
]
274
+ token_deletion_grant_types = [
275
+ Application .GRANT_AUTHORIZATION_CODE ,
276
+ Application .GRANT_IMPLICIT ,
277
+ Application .GRANT_PASSWORD ,
278
+ Application .GRANT_CLIENT_CREDENTIALS ,
279
+ Application .GRANT_OPENID_HYBRID ,
280
+ ]
272
281
273
282
def get_initial (self ):
274
283
return {
@@ -344,7 +353,9 @@ def do_logout(self, application=None, post_logout_redirect_uri=None, state=None)
344
353
AccessToken = get_access_token_model ()
345
354
RefreshToken = get_refresh_token_model ()
346
355
access_tokens_to_delete = AccessToken .objects .filter (
347
- user = self .request .user , application__client_type__in = self .token_types_to_delete
356
+ user = self .request .user ,
357
+ application__client_type__in = self .token_deletion_client_types ,
358
+ application__authorization_grant_type__in = self .token_deletion_grant_types ,
348
359
)
349
360
# This queryset has to be evaluated eagerly. The queryset would be empty with lazy evaluation
350
361
# because `access_tokens_to_delete` represents an empty queryset once `refresh_tokens_to_delete`
0 commit comments