Skip to content

Trust forwarded headers, clamp usage days and restart in one place - #21

Merged
bricke merged 1 commit into
mainfrom
fix/consistency-cleanups
Oct 1, 2026
Merged

bricke merged 1 commit into
mainfrom
fix/consistency-cleanups

Conversation

@bricke

@bricke bricke commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Fixes #20.

  • Proxy trust: one fromTrustedProxy / forwarded(header) in httpapi/server.go backs forwardedHost, clientIP and isHTTPS. All three now accept the shared secret or a configured proxy address, the same trust that names the user. auth.HasProxySecret is unexported, since nothing outside auth needs it. docs/install.md updated.
  • Usage days: Filter.days() clamps once, used by both the query and Summary.Days/fillDays.
  • Apply/restart: startHealthy replaces restart(ctx, config) and the copy inside Apply. The config is written before the router stops (Switchyard has no hot reload), so a failed write returns with the router untouched; previously a failed first write left the state at restarting.

Tests

  • TestForwardedHeadersTrustedLikeIdentity: address- and secret-trusted proxies report client IP and scheme, while others are ignored.
  • TestSummaryDaysMatchTheQuery: out-of-range days give 30-day summaries with 30 chart points.
  • go vet ./... and go test ./... pass.

Behind the trusted proxy, X-Forwarded-For and X-Forwarded-Proto are now
believed under the same rule as X-Forwarded-Host and the identity
headers: the shared secret or a configured proxy address.

The usage filter's days are clamped once, so the summary, its chart and
the query cover the same period.

Apply, rollback and Restart share one startHealthy. The new config is
written before the router stops (it reads its config only at start), so
a failed write leaves it running instead of stuck in "restarting".

Fixes #20
@bricke
bricke merged commit c3602d5 into main Oct 1, 2026
3 checks passed
@bricke
bricke deleted the fix/consistency-cleanups branch October 1, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent proxy trust, usage days clamp, and apply restart path

1 participant