Skip to content

fix(rest): wrap late-merged routers in the global layers (R-53, S-35) - #33

Merged
TurkerMertkan merged 1 commit into
developfrom
s35-late-routers
Nov 23, 2026
Merged

TurkerMertkan merged 1 commit into
developfrom
s35-late-routers

Conversation

@TurkerMertkan

Copy link
Copy Markdown
Collaborator

Summary

  • main.rs merged the tags, alerts, roxWarp/cluster and simulator routers after the global layers (request counter, rate limit, 1 MiB body limit, CORS), so those routes were outside them (R-53).
  • router_with_auth is split into rest::api_routes (routes + their auth layers) and rest::with_global_layers (same layers, same order); its signature is unchanged.
  • main.rs merges every router first and applies with_global_layers last. TLS and plain HTTP serve the same app.

Routes / auth

No auth decision changed. The global layers now also wrap /api/tags*, /api/alerts/*, /roxwarp, /api/cluster/* and the simulator routes. The 7443 cluster listener is out of scope (R-54).

Behavior change

Those routes share the global --rate-limit counter (429), reject bodies over 1 MiB (413, previously axum's 2 MiB Json default) and answer CORS preflight.

Test plan

  • New tests/global_layers.rs (5 tests) fails 5/5 on the old order, passes on the new one
  • bash tools/gates.sh: 2895 passed / 0 failed; simulator-hal check OK
  • Local E2E (--rate-limit 2): 429, 413, CORS headers and preflight on late routes
  • security-reviewer: no significant findings

🤖 Generated with Claude Code

https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC

main.rs merged the tags, alerts, roxWarp/cluster and simulator routers
after router_with_auth had applied the request counter, rate limit,
1 MiB body limit and CORS. axum layers only wrap routes added before
them, so those routes had no rate limit (unlimited bearer guesses once
auth is on), axum's 2 MiB Json default instead of 1 MiB, no CORS
preflight answer, and were not counted in /api/metrics.

Split router_with_auth into api_routes (core routes with their auth
layers, no global layers) and with_global_layers (same layers, same
order). router_with_auth keeps its signature and composes the two.
main.rs now merges every router first and applies with_global_layers
last; TLS and plain HTTP serve that same app.

Routes/auth: no auth decision changed. Every router keeps its own
require_auth / require_upgrade_auth or documented open routes. The
global layers now also wrap /api/tags*, /api/alerts/*, /roxwarp,
/api/cluster/* and the simulator routes. The 7443 cluster listener is
unchanged (R-54).

Behavior change: those routes share the global --rate-limit counter
(429 when exceeded), reject bodies over 1 MiB with 413, and answer
CORS preflight like the core routes.

Tests: new tests/global_layers.rs (429 on late GETs and before auth on
a late PUT, 413 on a 1.5 MiB PUT, CORS header and preflight); all 5
failed with the old order. auth_layer.rs builds the app in the new
order. gates: 2895 passed / 0 failed; simulator-hal check OK. Local
E2E with --rate-limit 2: 429, 413 and CORS headers on late routes.

Docs: OVERVIEW security notes, HARDCODED_LIMITS (body limit scope,
CORS line), routes-auth rule example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
@TurkerMertkan
TurkerMertkan merged commit 57e1c9c into develop Nov 23, 2026
2 checks passed
@TurkerMertkan
TurkerMertkan deleted the s35-late-routers branch November 23, 2026 12:15
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.

1 participant