ueffel / caddy-basic-auth-filter

Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

caddy-basic-auth-filter

This packages contains a log field filter to extract the user from a basic Authorization HTTP-Header.

Installation

xcaddy build --with github.com/ueffel/caddy-basic-auth-filter

Usage

See caddy log filter documentation. There will be a new filters to use:

<field> basic_auth_user
  • field Probably the only sensible field to use here is: request>headers>Authorization

Since caddy v2.5.0 logging of credentials needs to be enabled in the global server options with log_credentials for this filter to work. See caddyserver/caddy#4438.

Example configuration

The following example configuration uses the Formatted Log Encoder

format filter {
    wrap formatted "{request>host} {request>headers>Authorization} [{ts}] \"{request>method} {request>uri} {request>proto}\""
    fields {
        request>headers>Authorization basic_auth_user
    }
}
localhost admin [1620840157.514536] "GET /some/path HTTP/2.0" 

For reference the configuration and output without filters:

format formatted "{request>host} {request>headers>Authorization} [{ts}] \"{request>method} {request>uri} {request>proto}\""

Log output:

localhost ["Basic YWRtaW46YWRtaW4="] [1638732239.578346] "GET /some/path HTTP/2.0"

About

Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header


Languages

Language:Go 100.0%