https://github.com/ueffel/caddy-basic-auth-filter
Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header
https://github.com/ueffel/caddy-basic-auth-filter
caddy caddy-module caddy-plugin
Last synced: 5 months ago
JSON representation
Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header
- Host: GitHub
- URL: https://github.com/ueffel/caddy-basic-auth-filter
- Owner: ueffel
- Created: 2021-12-05T19:37:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-04T14:32:48.000Z (over 1 year ago)
- Last Synced: 2024-08-03T22:19:15.301Z (8 months ago)
- Topics: caddy, caddy-module, caddy-plugin
- Language: Go
- Homepage:
- Size: 62.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - ueffel/caddy-basic-auth-filter - Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header (Go)
README
# caddy-basic-auth-filter
This packages contains a log field filter to extract the user from a basic Authorization
HTTP-Header.## Installation
```sh
xcaddy build --with github.com/ueffel/caddy-basic-auth-filter
```## Usage
See [caddy log filter documentation](https://caddyserver.com/docs/caddyfile/directives/log#filter).
There will be a new filters to use:```caddy-d
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](https://caddyserver.com/docs/caddyfile/options#server-options) with `log_credentials` for
this filter to work. See .## Example configuration
The following example configuration uses the [Formatted Log
Encoder](https://github.com/caddyserver/format-encoder)```caddy-d
format filter {
wrap formatted "{request>host} {request>headers>Authorization} [{ts}] \"{request>method} {request>uri} {request>proto}\""
fields {
request>headers>Authorization basic_auth_user
}
}
``````plain
localhost admin [1620840157.514536] "GET /some/path HTTP/2.0"
```> For reference the configuration and output without filters:
>
> ```caddy-d
> format formatted "{request>host} {request>headers>Authorization} [{ts}] \"{request>method} {request>uri} {request>proto}\""
> ```
>
> Log output:
>
> ```plain
> localhost ["Basic YWRtaW46YWRtaW4="] [1638732239.578346] "GET /some/path HTTP/2.0"
> ```