Repository navigation
fix(rest): wrap late-merged routers in the global layers (R-53, S-35) - #33
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main.rsmerged 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_authis split intorest::api_routes(routes + their auth layers) andrest::with_global_layers(same layers, same order); its signature is unchanged.main.rsmerges every router first and applieswith_global_layerslast. 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-limitcounter (429), reject bodies over 1 MiB (413, previously axum's 2 MiBJsondefault) and answer CORS preflight.Test plan
tests/global_layers.rs(5 tests) fails 5/5 on the old order, passes on the new onebash tools/gates.sh: 2895 passed / 0 failed;simulator-halcheck OK--rate-limit 2): 429, 413, CORS headers and preflight on late routessecurity-reviewer: no significant findings🤖 Generated with Claude Code
https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC