Is it possible to persist a Basic Auth with caddy?

I successfully put my site behind a Basic Authentication {
    reverse_proxy hello:5050
	basicauth {

It works fine, prompting me for the password when I want to access my site, and lets me in when the password is correct.

The problem is that this authentication is not persistant, i.e. when I close my browser I have to re-authenticate.

Is there a way to make this persistant? It does not have to be a scalable solution, it is going to be for a handful of people and it can be indefinite.

I wanted to ask in case there is a simple solution before jumping into my own divagations (probably on how to verify a cookie, which is not a simple solution in case of mobile devices where manually setting a cookie is not an obvious task)

That’s how HTTP Basic Auth works. The browser remembers the credentials for some amount of time and sends them with every HTTP request. I guess if you close the browser, it forgets the credentials.

Basic auth should not really be used for sessions. Use cookies instead.

I have an application which does not have any authentication and I need it to have some.

One possibility was to have caddy to manage this (I was hoping for Basic Authentication, or otherwise check some cookies). A purely caddy-contained solution of sorts.

The alternative is for me to write an extra layer of proxy which would, upon successful login, set and then check cookies (or something like that, I did not give a deep thought yet - I wanted to make sure that there is no pre-cooked solution based on caddy :slight_smile: )

There are several existing third-party auth plugins for Caddy 2 that you can choose from:

This topic was automatically closed after 30 days. New replies are no longer allowed.