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

Headless SessionView for APP client creates an unnecessary session #3784

Closed
joonhyungshin opened this issue May 6, 2024 · 0 comments · Fixed by #3785
Closed

Headless SessionView for APP client creates an unnecessary session #3784

joonhyungshin opened this issue May 6, 2024 · 0 comments · Fixed by #3785

Comments

@joonhyungshin
Copy link
Contributor

In an APP context, when the client invokes DELETE on SessionView, a new empty and useless session is created in the session store and an associated session token is present in the response. Because this new session is empty, it can't be used to authenticate, so fortunately there isn't any security issue related to this.

In short, the following test fails:

def test_logout_no_token(app_client, user):
    app_client.force_login(user)
    resp = app_client.get(reverse("headless:app:account:current_session"))
    assert resp.status_code == 200
    resp = app_client.delete(reverse("headless:app:account:current_session"))
    assert resp.status_code == 401
    assert "session_token" not in resp.json()["meta"]

The problem is that Django's logout() function flushes the session which sets session.modified = True, but expose_session_token() attempts to create a new session token if session.modified = True. A simple fix would be to also check if the session data is empty.

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

Successfully merging a pull request may close this issue.

1 participant