amerkurev / scrapper

Web scraper with a simple REST API living in Docker and using a Headless browser and Readability.js for parsing.
https://scrapper.dev
Apache License 2.0
162 stars 25 forks source link

Add authentication #12

Closed nmpereira closed 5 months ago

nmpereira commented 5 months ago

Problem

As someone who self hosts scrapper, i want to be able to expose it to the internet without having others access it.

Feature request

Add some sort of authentication, even if its a simple user/pass or a secret string that would be required in the URL as a param to gain access to the scrapper.

Siutan commented 5 months ago

If basic auth is all you're after you can do it yourself pretty easily. If you're using Nginx you can follow the guide here to set up the route with a username and password.

amerkurev commented 5 months ago

Hey @nmpereira ! Good news, we already support basic authentication via Caddy server. Please check out the "HTTPS and Authentication" section in our documentation for setup instructions. Let me know if you need any further assistance!

nmpereira commented 5 months ago

@amerkurev I did see the section about caddy basic auth, from what i can see, it pops up a dialog box that the user needs to enter the username/password. This is all good for using the scrapper service manually, however, I want to use it via the api that scrapper exposes. For example

mydomain.com/api/article?url=https://github.com/amerkurev/scrapper

I was more so looking for something like

mydomain.com/api/article?url=https://github.com/amerkurev/scrapper&apikey=my-super-secret-key

I dont believe there's a way to do that via caddy currently

nmpereira commented 5 months ago

Closing this issue as i found a way to do it via caddy. A simple implementation is documented here: https://caddy.community/t/check-for-token-in-request-or-a-cookie-and-react-accordingly/17853