lewazo / boreale

:evergreen_tree: A very lightweight authentication service for Traefik

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication with a Token

plague-doctor opened this issue · comments

I love your project! I use it for some time and it is great, however recently I have stumbled upon a problem - how to authenticate an API endpoint?
Could you conciser to add a feature of a Token authentication?

Hey sorry for the long wait, for some reason I didn't receive any notifications for this issue.
So if I understand correctly, you have an API exposed through traefik and would like to protect it with an authentication? Right now this would already work with Boréale, since it uses standard cookies. Depending how the API is accessed, you simply need to make sure the cookie is sent on every request.

For example, if it's through a JavaScript app using the fetch API, you simply need to specify {credentials: true} in the fetch options.

If I'm mistaken then don't hesitate to clarify and I'll see what I can do.

Oh, this time I have not received your answer 😞 ...
I am not entirely sure how to achieve this using the curl command... What I was looking for was something similar to:
curl -u myusername:mypassword https://api.mysite.net
Any suggestion?

I see. Yeah I could definitely add a route that is better suited for headless login that would return a token or something.

Thank you for your suggestion. I'll definitely look into it!

For now, what you can do with curl is request the cookie like so :
curl -X GET -H "Auth-Form:username=your-username&password=your-password&action=login" https://api.mysite.net --cookie-jar my-cookie.txt

And then, in all further requests to the API, you could include the cookie like so :
curl -b my-cookie.txt https://api.mysite.net/