Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logoutall should use api_settings.DEFAULT_AUTHENTICATION_CLASSES ? #284

Open
skyl opened this issue Oct 16, 2022 · 1 comment
Open

Logoutall should use api_settings.DEFAULT_AUTHENTICATION_CLASSES ? #284

skyl opened this issue Oct 16, 2022 · 1 comment

Comments

@skyl
Copy link

skyl commented Oct 16, 2022

Hi, thanks for this library!

https://github.com/James1345/django-rest-knox/blob/3a1bc584f9691f4bc19d8a04a98c68c293be9ca6/knox/views.py#L94

Is there any reason why logoutall can't use all of the default auth classes by default? Seems like it works fine:

from rest_framework.settings import api_settings
from knox.views import LogoutAllView as KnoxLogoutAllView


class LogoutAllView(KnoxLogoutAllView):
    authentication_classes = api_settings.DEFAULT_AUTHENTICATION_CLASSES
urlpatterns = urlpatterns + [
    path('api/token/logoutall/', LogoutAllView.as_view(), name="knox_logout"),
    path('api/token/', include('knox.urls')),

It seems one of the best reasons to logoutall might be that you lost all of your tokens and just want to start over. So, basic or session auth would be good for this. I think the individual logout needs the token to know which token to delete though? Therefore I think it makes sense to leave authentication_classes = (TokenAuthentication,) for that one

https://github.com/James1345/django-rest-knox/blob/3a1bc584f9691f4bc19d8a04a98c68c293be9ca6/knox/views.py#L78-L86

@skyl
Copy link
Author

skyl commented Oct 16, 2022

If you like this idea - maybe this will work:

https://github.com/James1345/django-rest-knox/pull/285/files

@skyl skyl changed the title Logoutall should use Logoutall should use api_settings.DEFAULT_AUTHENTICATION_CLASSES ? Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant