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

Logging out not expiring session #282

Open
eliezerp3 opened this issue Oct 2, 2022 · 3 comments
Open

Logging out not expiring session #282

eliezerp3 opened this issue Oct 2, 2022 · 3 comments

Comments

@eliezerp3
Copy link

Hi. Thank you so much for this package. I have this

 'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
        'knox.auth.TokenAuthentication',
    ),

in my settings.py. Issue is that the log out view only expires the token but the browser still stays logged in due to the session still being valid. Is there any way to expire the session when the user logs out?

@yd4011439
Copy link

If you are previously logged in with session authentication then dfr/knox won't do anything to remove that session. Try deleting the cookies and then next time it may not occur.

@eliezerp3
Copy link
Author

@yd4011439 Unfortunately that doesn’t help. It seems it uses both session and token upon login but only expires the token (and not the session) upon logout.

@ge-lem
Copy link

ge-lem commented Nov 4, 2023

Same error using the tutorial https://jazzband.github.io/django-rest-knox/auth/

class LoginView(KnoxLoginView):
    permission_classes = (permissions.AllowAny,)

    def post(self, request, format=None):
        serializer = AuthTokenSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        user = serializer.validated_data['user']
        login(request, user)
        return super(LoginView, self).post(request, format=None)

login(request, user) create the session cookie.

I also overide the LogoutView

class LogoutView(KnoxLogoutView):
    def post(self, request, format=None):
        response = super(LogoutView, self).post(request, format=None)
        logout(request)
        return response

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

3 participants