django-rest-knox
django-rest-knox copied to clipboard
Logoutall should use api_settings.DEFAULT_AUTHENTICATION_CLASSES ?
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
If you like this idea - maybe this will work:
https://github.com/James1345/django-rest-knox/pull/285/files