caddy: caddy not logging basic authentication failures

relates to #2402 which was implemented Feb 2019 pre-v2.

when using basicauth to authenticate it would be nice to use fail2ban to detect multiple failed login attempts and ban ip addresses. this is difficult with the current logging since every basic authentication attempt starts with a 401 and thus banning on this results in many false positives.

see #2402 for further details and reasoning.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 26 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@sumnerboy12 You had the actual use case for it. We’re not going to implement a new feature just because. Since it is no longer required, it will not be implemented. My time must be spent on things that will make a difference to the project and its users, not “nice to haves” (especially when they take so much time like this feature).

Technically you don’t know the identity, because they haven’t successfully authenticated. You have a username, but that’s not enough to say that you know who it is. 401 is definitely the correct status code to return on a failed authentication.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401

The HTTP 401 Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.

This status is similar to 403, but in this case, authentication is possible.

What if they’re like me and type their password wrong twice? 😛

I guess I’m just trying to see the need to motivate a change in Caddy. AFAICT everything is working as expected, it’s just that your fail2ban is too strict probably.

yes - agree it is the correct behaviour, and then if an actual authentication attempt fails we also get a 401 (again correct).

however trying to configure fail2ban to ban on just the 401s results in false positives since every time an authentication attempt is started a 401 is logged and this eventually triggers the ban.

so ideally we have some specific auth failed logging which fail2ban can monitor instead of the 401s.

hope that is a little clearer…