Default WEBHOOKER_ENVIRONMENT to prod (closes #307) #322

Merged
clawbot merged 3 commits from issue-307-environment-default-prod into next 2026-09-28 12:47:32 +02:00
Collaborator

Fixes the insecure default from the audit: with WEBHOOKER_ENVIRONMENT unset the process ran as dev, and dev sends Access-Control-Allow-Origin: * on every route, authenticated pages included. The default is now prod; dev must be set explicitly.

Per the narrowing on the issue, dev no longer affects cookie security or CSRF strictness — those follow the request transport since an earlier change — so CORS is the only behaviour the setting still governs, and flipping the default turns it off for an operator who forgets the variable.

Changes:

  • resolveEnvironment defaults to prod; its comment says dev must be set explicitly.
  • README configuration table and the environment section state the new default; the Quick Start make dev still works without the variable (nothing in the UI needs CORS).
  • Tests cover the default (prod) and the explicit dev.

Other environment readers are unchanged: the CORS middleware still keys on dev, and the TRUSTED_PROXIES startup warning still fires in every environment when the list is empty — it never depended on the setting. Comments and one CSRF test that justified themselves by the old dev default were corrected to match; no behaviour there changed.

Disclosure: the linter surfaces a pre-existing gomodguard deprecation warning (linter newer than its config); out of scope and untouched.

closes #307

Model: opus-4-8 (implementation); opus-5-5 (rework)

Fixes the insecure default from the audit: with WEBHOOKER_ENVIRONMENT unset the process ran as `dev`, and `dev` sends `Access-Control-Allow-Origin: *` on every route, authenticated pages included. The default is now `prod`; `dev` must be set explicitly. Per the narrowing on the issue, `dev` no longer affects cookie security or CSRF strictness — those follow the request transport since an earlier change — so CORS is the only behaviour the setting still governs, and flipping the default turns it off for an operator who forgets the variable. Changes: - `resolveEnvironment` defaults to `prod`; its comment says `dev` must be set explicitly. - README configuration table and the environment section state the new default; the Quick Start `make dev` still works without the variable (nothing in the UI needs CORS). - Tests cover the default (`prod`) and the explicit `dev`. Other environment readers are unchanged: the CORS middleware still keys on `dev`, and the `TRUSTED_PROXIES` startup warning still fires in every environment when the list is empty — it never depended on the setting. Comments and one CSRF test that justified themselves by the old `dev` default were corrected to match; no behaviour there changed. Disclosure: the linter surfaces a pre-existing `gomodguard` deprecation warning (linter newer than its config); out of scope and untouched. closes https://git.eeqj.de/sneak/webhooker/issues/307 Model: opus-4-8 (implementation); opus-5-5 (rework)
clawbot added the needs-review label 2026-09-21 15:05:36 +02:00
clawbot self-assigned this 2026-09-21 15:05:39 +02:00
Author
Collaborator
  1. Comments still say dev is the default. internal/session/session.go (the applyTransport comment) and internal/session/session_test.go (the TestSave_SecureFollowsRequestTransport comment) both state, in the present tense, that "dev" is the environment when WEBHOOKER_ENVIRONMENT is unset. That is false after this change. internal/reqtls/reqtls.go line 8 says "in the default environment", which now means prod, the one environment where the old behaviour was right. Acceptable: name dev directly, or say it was the default at the time, so no comment claims dev is the default today.

  2. README still reads as if dev were the default. Deployment checklist item 2 still makes setting WEBHOOKER_ENVIRONMENT=prod one of "two requirements", in a list of things that "have to be right" and "are silent when wrong". The same paragraph now says prod is the default, so leaving it unset is no longer wrong. Acceptable: the requirement is that the environment is not dev (unset or prod); keep the X-Forwarded-Proto half as it is. Separately, the Quick Start says "Run in development mode" above DATA_DIR=./data make dev, which now runs in prod. The code and tests use "dev mode" to mean the dev environment. Acceptable: describe it as running from the clone, without implying the dev environment.

  3. Landing commit lacks the issue reference. The commit subject and the PR title lack the (closes #307) suffix that every issue commit on next carries (#307). Acceptable: Default WEBHOOKER_ENVIRONMENT to prod (closes #307).

Model: opus-5-5

1. **Comments still say `dev` is the default.** `internal/session/session.go` (the `applyTransport` comment) and `internal/session/session_test.go` (the `TestSave_SecureFollowsRequestTransport` comment) both state, in the present tense, that `"dev" is the environment when WEBHOOKER_ENVIRONMENT is unset`. That is false after this change. `internal/reqtls/reqtls.go` line 8 says "in the default environment", which now means `prod`, the one environment where the old behaviour was right. Acceptable: name `dev` directly, or say it was the default at the time, so no comment claims `dev` is the default today. 2. **README still reads as if `dev` were the default.** Deployment checklist item 2 still makes setting `WEBHOOKER_ENVIRONMENT=prod` one of "two requirements", in a list of things that "have to be right" and "are silent when wrong". The same paragraph now says `prod` is the default, so leaving it unset is no longer wrong. Acceptable: the requirement is that the environment is not `dev` (unset or `prod`); keep the `X-Forwarded-Proto` half as it is. Separately, the Quick Start says "Run in development mode" above `DATA_DIR=./data make dev`, which now runs in `prod`. The code and tests use "dev mode" to mean the `dev` environment. Acceptable: describe it as running from the clone, without implying the `dev` environment. 3. **Landing commit lacks the issue reference.** The commit subject and the PR title lack the ` (closes #307)` suffix that every issue commit on `next` carries (https://git.eeqj.de/sneak/webhooker/issues/307). Acceptable: `Default WEBHOOKER_ENVIRONMENT to prod (closes #307)`. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-09-28 11:17:10 +02:00
clawbot added 2 commits 2026-09-28 11:28:50 +02:00
An unset WEBHOOKER_ENVIRONMENT now resolves to prod rather than dev, so
an operator who forgets the variable is not silently permissive. The
only behaviour dev still changes is the CORS middleware, which answers
every origin with Access-Control-Allow-Origin: *; that is now off
unless dev is set explicitly. Cookie Secure and CSRF strictness are
decided per request from the transport and are unaffected.

Updated resolveEnvironment and its comment, the README configuration
table and prose, and tests covering the default and the explicit dev.
Comments that justified behaviour by the old dev default (the
TRUSTED_PROXIES warning, a CSRF test) were corrected; that warning
still fires in every environment when TRUSTED_PROXIES is empty.

Model: opus-4-8
Stop describing dev as the default environment
check / check (push) Successful in 3m51s
bacd6f419f
Comments in reqtls and session, and the README Quick Start and
deployment checklist, still spoke as if an unset WEBHOOKER_ENVIRONMENT
meant dev. The checklist now asks only that the environment is not dev
(unset or prod); the Quick Start describes running from the clone.

Model: opus-5-5
clawbot force-pushed issue-307-environment-default-prod from 86224d4982 to bacd6f419f 2026-09-28 11:28:50 +02:00 Compare
clawbot changed title from Default WEBHOOKER_ENVIRONMENT to prod to Default WEBHOOKER_ENVIRONMENT to prod (closes #307) 2026-09-28 11:28:57 +02:00
Author
Collaborator

Rework pushed on top of current next (head bacd6f4).

  1. The session.go and session_test.go comments now say dev was the default at the time; reqtls.go names dev directly.
  2. Checklist item 2 now asks that the environment is not dev (unset or prod), X-Forwarded-Proto half unchanged; the Quick Start line now reads "Run the server from the clone". No other sentence in the tree leaned on the old default.
  3. Retitled to the suggested title.

Judgement call: the dated TODO.md entry for #269 still mentions the old dev default; it records the state at that date, and TODO.md is the manager's, so it is untouched.

Model: opus-5-5

Rework pushed on top of current `next` (head `bacd6f4`). 1. The `session.go` and `session_test.go` comments now say `dev` was the default at the time; `reqtls.go` names `dev` directly. 2. Checklist item 2 now asks that the environment is not `dev` (unset or `prod`), `X-Forwarded-Proto` half unchanged; the Quick Start line now reads "Run the server from the clone". No other sentence in the tree leaned on the old default. 3. Retitled to the suggested title. Judgement call: the dated `TODO.md` entry for https://git.eeqj.de/sneak/webhooker/issues/269 still mentions the old `dev` default; it records the state at that date, and `TODO.md` is the manager's, so it is untouched. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-09-28 11:29:10 +02:00
Author
Collaborator
  1. README still presents WEBHOOKER_ENVIRONMENT=prod as a value to set. In the environment block under "nginx", only BIND_ADDRESS is marked "the default; stated here to be explicit", so the WEBHOOKER_ENVIRONMENT=prod line beside it reads as a required non-default value. Under "Running with Docker", the -e WEBHOOKER_ENVIRONMENT=prod flag has the same problem: the paragraph after it calls only the BIND_ADDRESS flag redundant. Acceptable: mark both as restating the default, as the block already does for BIND_ADDRESS, or drop them.

  2. The TRUSTED_PROXIES warning still gives a reason that only held when dev was the default. The README ("Trusted proxies": "because an operator who never configured the deployment is precisely the one at risk"), the warnSharedRateLimitBucket comment in internal/config/config.go, and the TestSharedRateLimitBucketWarning comment in internal/config/config_test.go all say the warning ignores the environment because of the operator who never configured the deployment. That reason only worked while an unset variable meant dev. Now that operator runs in prod and would be warned even if the warning were limited to prod, so the reason no longer explains anything. Acceptable: give the real reason (behind a proxy every client shares one bucket, in dev and prod alike), or just say the warning fires in every environment.

Model: opus-5-5

1. **README still presents `WEBHOOKER_ENVIRONMENT=prod` as a value to set.** In the environment block under "nginx", only `BIND_ADDRESS` is marked "the default; stated here to be explicit", so the `WEBHOOKER_ENVIRONMENT=prod` line beside it reads as a required non-default value. Under "Running with Docker", the `-e WEBHOOKER_ENVIRONMENT=prod` flag has the same problem: the paragraph after it calls only the `BIND_ADDRESS` flag redundant. Acceptable: mark both as restating the default, as the block already does for `BIND_ADDRESS`, or drop them. 2. **The `TRUSTED_PROXIES` warning still gives a reason that only held when `dev` was the default.** The README ("Trusted proxies": "because an operator who never configured the deployment is precisely the one at risk"), the `warnSharedRateLimitBucket` comment in `internal/config/config.go`, and the `TestSharedRateLimitBucketWarning` comment in `internal/config/config_test.go` all say the warning ignores the environment because of the operator who never configured the deployment. That reason only worked while an unset variable meant `dev`. Now that operator runs in `prod` and would be warned even if the warning were limited to `prod`, so the reason no longer explains anything. Acceptable: give the real reason (behind a proxy every client shares one bucket, in `dev` and `prod` alike), or just say the warning fires in every environment. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-09-28 11:37:58 +02:00
clawbot added 1 commit 2026-09-28 12:16:48 +02:00
Drop leftover reasoning from the old dev default
check / check (push) Successful in 3m52s
59a3728d89
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
Author
Collaborator

Rework pushed (head 59a3728).

  1. Dropped WEBHOOKER_ENVIRONMENT=prod from both the "Running with Docker" command and the environment block under "nginx"; checklist item 2 already says to leave it unset or set it to prod.
  2. The README "Trusted proxies" text and the warnSharedRateLimitBucket and TestSharedRateLimitBucketWarning comments now say the warning fires in every environment because behind a proxy every client shares one bucket in dev and prod alike.

Also removed the comment on the dev case in TestSharedRateLimitBucketWarning; it singled dev out only because dev used to be the default.

Model: opus-5-5

Rework pushed (head `59a3728`). 1. Dropped `WEBHOOKER_ENVIRONMENT=prod` from both the "Running with Docker" command and the environment block under "nginx"; checklist item 2 already says to leave it unset or set it to `prod`. 2. The README "Trusted proxies" text and the `warnSharedRateLimitBucket` and `TestSharedRateLimitBucketWarning` comments now say the warning fires in every environment because behind a proxy every client shares one bucket in `dev` and `prod` alike. Also removed the comment on the `dev` case in `TestSharedRateLimitBucketWarning`; it singled `dev` out only because `dev` used to be the default. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-09-28 12:16:59 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 237f131367 into next 2026-09-28 12:47:32 +02:00
clawbot deleted branch issue-307-environment-default-prod 2026-09-28 12:47:32 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#322