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

CRSFtoken wrong cookie path ? #1849

Closed
abubelinha opened this issue Oct 9, 2022 · 1 comment
Closed

CRSFtoken wrong cookie path ? #1849

abubelinha opened this issue Oct 9, 2022 · 1 comment
Assignees
Milestone

Comments

@abubelinha
Copy link
Contributor

When trying twill-based variations of @sylmorin-gbif script in #1480, a possible new issue about IPT CSRFtoken wrong cookie path has arosen.

If I use Chrome developer tool Network tab and then select login.do to see its Cookies tab, the Request Cookies section shows / as the Path for all cookies (including CSRFtoken), whereas the Response Cookies section always shows "" as the Path for CSRFtoken.
Looks like that might be interfering with IPT login process from some browsers, and might be related to other issues.
This goes far beyond my understanding, so I thank @Cito and paste here his comments taken from twill-tools/twill#11:

I think the reason why it [twill] does not work is that your site [demo IPT] sends a strange cookie path (two quotes instead of an actual path). I guess it only works in some browsers because they silently "correct" the path.
I guess it's the ipt web app or its configuration. The cookie path is set in its CsrfLoginInterceptor class, and something probably is not done right there. It also catches and ignores all Exceptions when setting the path, which does not look clean to me.
#1652 could be related to this.
psf/requests#6245 also looks related to this.
You can tag me [@Cito], but currently I do not have the time to look deeper into these issues.

The crucial issue here is that cookies can have a domain and a path attribute which specify for which domains and URL paths they shall be valid and sent to the server. If the client (the browser or Twill) thinks the path does not match, it does not send the cookie. The behavior if the server sends an invalid path (as ipt is doing) is undefined. Chrome seems to send the cookie anyway in this case, but the RequestsCookieJar does not. Maybe the RequestsCookieJar should be more sloppy as well.

@mike-podolskiy90
Copy link
Contributor

@abubelinha Thank you for reporting the issue.
Something's wrong with the token indeed. I'll investigate

@mike-podolskiy90 mike-podolskiy90 self-assigned this Oct 10, 2022
@mike-podolskiy90 mike-podolskiy90 added this to the 2.6.3 milestone Oct 10, 2022
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

2 participants