The README Docker and nginx examples no longer set WEBHOOKER_ENVIRONMENT=prod, which is now the default. The TRUSTED_PROXIES warning text in the README, config.go and its test now gives the real reason it ignores the environment: behind a proxy every client shares one bucket in dev and prod alike. Model: opus-5-5
This commit is contained in:
@@ -400,10 +400,9 @@ the bucket is. See [Rate Limiting](#rate-limiting).
|
|||||||
|
|
||||||
The remedy is to set `TRUSTED_PROXIES` to your reverse proxy's
|
The remedy is to set `TRUSTED_PROXIES` to your reverse proxy's
|
||||||
address, which restores per-client buckets. webhooker logs a warning
|
address, which restores per-client buckets. webhooker logs a warning
|
||||||
at startup whenever `TRUSTED_PROXIES` is empty, in every environment —
|
at startup whenever `TRUSTED_PROXIES` is empty, in every environment,
|
||||||
the warning does not depend on `WEBHOOKER_ENVIRONMENT`, because an
|
because behind a proxy every client shares one bucket in `dev` and
|
||||||
operator who never configured the deployment is precisely the one at
|
`prod` alike. The warning is informational when nothing proxies to the
|
||||||
risk. The warning is informational when nothing proxies to the
|
|
||||||
process: with no proxy in front, the peer address is the client's own
|
process: with no proxy in front, the peer address is the client's own
|
||||||
and the buckets are already per-client. See
|
and the buckets are already per-client. See
|
||||||
[Rate Limiting](#rate-limiting) for what each limit shares.
|
[Rate Limiting](#rate-limiting) for what each limit shares.
|
||||||
@@ -639,7 +638,6 @@ decision:
|
|||||||
docker run -d \
|
docker run -d \
|
||||||
-p 127.0.0.1:8080:8080 \
|
-p 127.0.0.1:8080:8080 \
|
||||||
-v /path/to/data:/var/lib/webhooker \
|
-v /path/to/data:/var/lib/webhooker \
|
||||||
-e WEBHOOKER_ENVIRONMENT=prod \
|
|
||||||
-e BIND_ADDRESS=0.0.0.0 \
|
-e BIND_ADDRESS=0.0.0.0 \
|
||||||
webhooker:latest
|
webhooker:latest
|
||||||
```
|
```
|
||||||
@@ -856,7 +854,6 @@ sent — `$scheme` above does.
|
|||||||
With that block, webhooker's environment is:
|
With that block, webhooker's environment is:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
WEBHOOKER_ENVIRONMENT=prod
|
|
||||||
BIND_ADDRESS=127.0.0.1 # the default; stated here to be explicit
|
BIND_ADDRESS=127.0.0.1 # the default; stated here to be explicit
|
||||||
TRUSTED_PROXIES=127.0.0.1
|
TRUSTED_PROXIES=127.0.0.1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -774,10 +774,8 @@ func (c *Config) warnEgressAllowlist(log *slog.Logger) {
|
|||||||
// everyone else's wrong passwords, and the receiver's limits become
|
// everyone else's wrong passwords, and the receiver's limits become
|
||||||
// service-wide ceilings.
|
// service-wide ceilings.
|
||||||
//
|
//
|
||||||
// The warning is deliberately not gated on WEBHOOKER_ENVIRONMENT: an
|
// The warning is deliberately not gated on WEBHOOKER_ENVIRONMENT:
|
||||||
// operator who never configured the deployment is exactly the case it
|
// behind a proxy every client shares one bucket in dev and prod alike.
|
||||||
// exists to catch, so the exposure it announces is independent of the
|
|
||||||
// environment setting.
|
|
||||||
//
|
//
|
||||||
// The default of trusting nobody is deliberate — trusting forwarded
|
// The default of trusting nobody is deliberate — trusting forwarded
|
||||||
// headers from arbitrary peers lets any client choose its own bucket —
|
// headers from arbitrary peers lets any client choose its own bucket —
|
||||||
|
|||||||
@@ -849,9 +849,8 @@ func TestEgressAllowlistWarning(t *testing.T) {
|
|||||||
// rate-limit bucket between every client, which turns the receiver
|
// rate-limit bucket between every client, which turns the receiver
|
||||||
// limits into service-wide ceilings and collapses login failure
|
// limits into service-wide ceilings and collapses login failure
|
||||||
// counting. It must fire whenever TRUSTED_PROXIES is empty, in any
|
// counting. It must fire whenever TRUSTED_PROXIES is empty, in any
|
||||||
// environment: the warning does not depend on WEBHOOKER_ENVIRONMENT,
|
// environment, because behind a proxy every client shares one bucket
|
||||||
// since an operator who never configured the deployment is exactly the
|
// in dev and prod alike. It stays quiet once proxies are named.
|
||||||
// one it exists to catch. It stays quiet once proxies are named.
|
|
||||||
func TestSharedRateLimitBucketWarning(t *testing.T) {
|
func TestSharedRateLimitBucketWarning(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -871,9 +870,6 @@ func TestSharedRateLimitBucketWarning(t *testing.T) {
|
|||||||
expectWarning: false,
|
expectWarning: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// An internet-exposed deployment whose operator set
|
|
||||||
// WEBHOOKER_ENVIRONMENT=dev has exactly the exposure
|
|
||||||
// the warning announces.
|
|
||||||
name: "dev without trusted proxies warns",
|
name: "dev without trusted proxies warns",
|
||||||
environment: config.EnvironmentDev,
|
environment: config.EnvironmentDev,
|
||||||
expectWarning: true,
|
expectWarning: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user