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

v1.9.528 doesn't include credentials on chrome #8888

Closed
tsalufe opened this issue Sep 8, 2017 · 7 comments
Closed

v1.9.528 doesn't include credentials on chrome #8888

tsalufe opened this issue Sep 8, 2017 · 7 comments

Comments

@tsalufe
Copy link

tsalufe commented Sep 8, 2017

We had this code to get pdf through authenticated url
PDFJS.getDocument(url)
that breaks with version 1.9.528 on Chrome because it doesn't include CSRF-TOKEN in the request. However, it works on firefox and safari. Now I have to fix it by enforce withCredentials: true. Does new version set the default of withCredentials to false?

@yurydelendik
Copy link
Contributor

We are switching to more efficient fetch() instead of XHR. The defaults might change, let us know which default in https://developer.mozilla.org/en-US/docs/Web/API/Request/Request affects CSRF-TOKEN. If it's possible we will try to address this. Also notice that we don't want to make PDF.js less secure (even if we supported this in the past)

@tsalufe
Copy link
Author

tsalufe commented Sep 8, 2017

I'm not sure about that. Maybe credentials ?

credentials: The request credentials you want to use for the request: omit, same-origin, or include. The default is omit. In Chrome the default is same-origin before Chrome 47 and include starting with Chrome 47.

@mukulmishra18
Copy link
Contributor

I'm not sure about that. Maybe credentials ?

We are including credentials, if withCredentials is set, see:

credentials: withCredentials ? 'include' : 'omit',

I think that is why it works when you set withCredentials: true.

@tsalufe
Copy link
Author

tsalufe commented Sep 8, 2017

I think so.

@yurydelendik
Copy link
Contributor

Okay, from reading https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials, I have impression that to be compatible with XHR we need to use 'same-origin' instead of 'omit' there. I think it is safe in our context.

@tsalufe
Copy link
Author

tsalufe commented Sep 8, 2017

I think include definitely works for me since it's the setting of credentials when I set withCredentials to true. same-origin might limit the pdf on the same site, i.e not allowing authenticated access to pdf's on another site?

@yurydelendik
Copy link
Contributor

same-origin might limit the pdf on the same site, i.e not allowing authenticated access to pdf's on another site

That's how XHR worked before we introduced fetch().

mukulmishra18 added a commit to mukulmishra18/pdf.js that referenced this issue Sep 14, 2017
yurydelendik added a commit that referenced this issue Sep 14, 2017
Fix #8888: Change behaviour of fetch to make it compatible with XHR.
movsb pushed a commit to movsb/pdf.js that referenced this issue Jul 14, 2018
movsb pushed a commit to movsb/pdf.js that referenced this issue Jul 14, 2018
Fix mozilla#8888: Change behaviour of fetch to make it compatible with XHR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants