msokk / electron-render-service

Microservice for rendering PDF/PNG/JPEG from HTML with Electron
MIT License
102 stars 31 forks source link

How to use the service with a wikimedia page that needs authentication? #89

Open jlvale opened 5 years ago

jlvale commented 5 years ago

I'm testing the service right now but the .pdf files I download contains the default "authentication needed" page. How do I pass the credentials of my wiki to the service?

msokk commented 5 years ago

Basic auth? Or login page?

API has no authentication logic, either this service usually sits in private network, hitting against private urls. I have used unique urls like GUID-s or hashes.

If you have standard basic auth, you can always add credentials to URL - http://username:password@example.com/my_page

jlvale commented 5 years ago

It's a login page for a private wiki, we integrated the authentication with the Active Directory service.

msokk commented 5 years ago

Ah ok, that's tricky with current version. One option would be to implement some cookie parameter to set auth cookie, but this would still needs some automation to generate the cookie value.

Probably it would be best for you to use https://github.com/GoogleChrome/puppeteer or something based off of this, to automate login and PDF capture.

I'm planning to mark this project unmaintained soon as there are better, more lightweight alternatives to PDF rendering than electron.

jlvale commented 5 years ago

What alternative do you recommend?

msokk commented 5 years ago

Probably it would be easiest to script a puppeteer flow in Node.js yourself - https://blog.risingstack.com/pdf-from-html-node-js-puppeteer/