Skip to content

Conversation

allen-munsch
Copy link
Contributor

@allen-munsch allen-munsch commented Sep 24, 2019

Which causes 403 errors.

Screenshot from 2019-09-24 09-11-47
For example:

Cookie: csrftoken=asdfasd; sessionid=asdfasdf; csrftoken=qwertyqwerty

This can happen when multiple csrftokens for different paths.

For example: 

`Cookie: csrftoken=asdfasd; sessionid=asdfasdf; csrftoken=qwertyqwerty`

This can happen when multiple sessions, or multiple csrftokens for different paths.
@allen-munsch
Copy link
Contributor Author

related: #585

@stale
Copy link

stale bot commented Dec 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 23, 2019
@zbyte64 zbyte64 requested a review from danpalmer December 25, 2019 23:14
Copy link
Member

@jkimbo jkimbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allen-munsch can you elaborate more on why there would be multiple csrf tokens set?My understanding is that there should only be 1 token set at any time.

headers['X-CSRFToken'] = cookies.csrftoken.pop();
console.log('retry', headers)
return getFetch(headers);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be other reasons why the GraphQL endpoint doesn't return valid JSON so always assuming it's to do with a csrf token issue doesn't feel right.

Copy link
Contributor Author

@allen-munsch allen-munsch Dec 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkimbo see: https://stackoverflow.com/questions/576535/cookie-path-and-its-accessibility-to-subfolder-pages

From what I understand, the cookie sub path /2/m/2 would have both it's subpath cookie and the root path cookie. /.

The two paths have different database multitenancy requirements. It would probably be more accurate to read the cookie path directly, instead of just reading, checking them all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I understand that cookies can have different paths but looking at the Django source code the csrf cookie should be set to a path that is defined in the settings: https://github.com/django/django/blob/5a68f024987e6d16c2626a31bf653a2edddea579/django/middleware/csrf.py#L191

So I don't think it's possible to have 2 csrf cookies at the same time and I'm wondering how that came about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoints per multi tenancy. localhost:8000/:multitenantid/endpoints/here so multiple users can get different csrftoken cookies on a single machine ... it's not the default of django, but it is a real use case.

Copy link
Member

@jkimbo jkimbo Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't realise that was possible! Could you not host the graphql endpoint per tenant as well or those that not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants