Skip to content

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

Notifications You must be signed in to change notification settings

ueffel/caddy-basic-auth-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages