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

Samesite setting not being set on HttpOnly token delete #288

Open
aaonhub opened this issue Sep 8, 2021 · 4 comments
Open

Samesite setting not being set on HttpOnly token delete #288

aaonhub opened this issue Sep 8, 2021 · 4 comments

Comments

@aaonhub
Copy link

aaonhub commented Sep 8, 2021

sorry if there's some standard I'm not following it's my first github issue submission

I don't know why but getting the token works fine but trying to delete it ignores the samesite setting.

My django settings (I tried commenting out the samesite setting but nothing changed):

GRAPHQL_JWT = {
    "JWT_COOKIE_SECURE": True,
    "JWT_COOKIE_SAMESITE": "None",

    # optional
    "JWT_LONG_RUNNING_REFRESH_TOKEN": True,
}

My apollo client HttpLink:

 const link = new HttpLink({
	uri: 'http://127.0.0.1:8000/',
	credentials: 'include',
 });

Token mutation

image

Deleting token mutation

image

@letops
Copy link

letops commented Oct 11, 2021

Can confirm. This same thing is happening to me, the only difference is that I am not using the Long Running Refresh Tokens

@aaonhub
Copy link
Author

aaonhub commented Nov 15, 2021

I feel like this a pretty major bug. Is nobody else having this problem?

@cadiente-jomel
Copy link

@aaonhub I'm having the same problem, did you already solve the problem?

@JamieOWilliams
Copy link

It looks like the method used to delete cookies simply ignores the samesite setting.

def delete_cookie(response, key):
response.delete_cookie(
key,
path=jwt_settings.JWT_COOKIE_PATH,
domain=jwt_settings.JWT_COOKIE_DOMAIN,
)

After a quick test the following change works:

def delete_cookie(response, key):
    kwargs = {
        "path": jwt_settings.JWT_COOKIE_PATH,
        "domain": jwt_settings.JWT_COOKIE_DOMAIN,
    }
    if django.VERSION >= (2, 1):
        kwargs["samesite"] = jwt_settings.JWT_COOKIE_SAMESITE

    response.delete_cookie(key, **kwargs)

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

4 participants