marklieberman / downloadstar

Download all items in a webpage that match a pattern
GNU General Public License v3.0
90 stars 16 forks source link

Download fails if I'm authenticated #72

Closed pandronic closed 4 years ago

pandronic commented 5 years ago

I download invoices every months from a CMS. They are all linked in a page a have an URL similar to this: http://example.com/invoices/invoice_number.pdf

The PDFs are generated on the fly. The CMS first checks if the user is authenticated (by checking a variable in the current session) and then returns the document. If the user is not authenticated it triggers a redirect to the login page.

This worked fine last time I tried (end of April). Now Download Star returns the login page, not the PDF (as if the user is not logged in)

I changed the requirement in the invoice generating script for the user to be logged in and Download Star works again, but obviously I don't want to leave it like this.

Using latest version of Firefox (67.0.1) and Download Star (2.0.2)

ngg71 commented 5 years ago

I have exactly the same issue. Was working a few weeks ago and now downloads the login page .

pandronic commented 5 years ago

So, I did a little bit of testing. Things work as usual in Firefox 66.0.4, so something happened in Firefox 67.

The download request doesn't include any cookies. I'm not sure if this is a Firefox bug/change or a Download Star bug.

Normal request:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.5
Cookie: foo=bar
Host: www.example.com
Referer: https://www.example.com/test2.php
Te: trailers
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
X-Https: 1

Download Star request on Firefox 67:

Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.5
Host: www.example.com
Te: trailers
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
X-Https: 1

Download Star request on Firefox 66:

Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.5
Cookie: foo=bar
Host: www.example.com
Te: trailers
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
X-Https: 1
emcmurray commented 5 years ago

It's likely related to the changes to prevent third party cookies from tracking changes that occurred in version 67 https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy

emcmurray commented 5 years ago

For people who need an immediate solution - the ESR version of firefox will still allow you to work with download star and pages that require cookies. https://www.mozilla.org/en-US/firefox/organizations/

Reading through, I think that if permissions manifest gets updated to include cookies, that download star might be able to work again.... https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/cookies https://github.com/mdn/webextensions-examples/blob/master/cookie-bg-picker/manifest.json <-the current manifest doesn't include cookies like this one does.

byteit101 commented 5 years ago

At least on linux, 60.7.1esr doesn't correctly send cookies either

byteit101 commented 5 years ago

Might be a Fx bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1561654

I tried adding the cookies permission and it didn't solve it. A minimal rack server I used to test this: https://gist.github.com/byteit101/2750e81d10a22f7c0b2ad8290c894139

pandronic commented 5 years ago

The problem was fixed by Fx 69. Nice.