Repository navigation
security(api): gate the 14 remaining ungated mutating routers — sign-in for reads, admin for shared-state writes (#16375) - #18351
Merged
Conversation
…te writes (#16375) Slice 1 of the config-registered remainder. Each router now depends on auth_middleware.get_current_user at router level, the mechanism #17729 used, so every route needs a signed-in caller. Routes that change state shared by every user also depend on check_admin_permission: - validation_dashboard: POST /generate (mutates the shared generator) - code_search: POST /index, DELETE /cache - search: POST /optimize - analytics_pattern_learning: POST /patterns, POST /learn - error_resilience: both resets - knowledge_eval: POST /test/rebuild_index - phases: POST /validation/run (persists project state, as project_state does) - code_completion: POST /extract - feedback: POST /retrain - model_management: POST /train, POST /models/{version}/activate Every frontend caller already goes through ApiClient, ApiRepository or useFetchEndpoint, which send the bearer token; no SLM or internal HTTP caller exists for these prefixes. KNOWN_UNGATED shrinks 16 -> 2 (prometheus_endpoint and rum stay, parked on an owner ruling). Six of the routers sat at their size ceiling, so static tables and records moved to sibling modules and the ceilings were lowered. test_router_auth_16375.py now covers all 21 routers: anonymous 401 on every route, non-admin 403 on every admin route, and 422 contrasts proving the gate admits users and admins without running handlers.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
This was referenced Oct 12, 2026
This was referenced Oct 12, 2026
Merged
Merged
Open
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.
Thinking Path
#16375 (priority: critical): config-registered routers declared no auth gate. Before this PR, the #16370 guard's
KNOWN_UNGATEDbaseline held 16 of them, most of them mutating routes with no evidence of being public, the validation dashboard first. This slice gates every one of them except the two still waiting on an owner ruling. It uses the same mechanism #17729 and #16896 used: no new auth path, and no dependency on the still-open #18338.What Changed
dependencies=[Depends(get_current_user)]. Every route that changes shared state additionally requiresDepends(check_admin_permission); server-wide operations are admin-only per the owner's rule.autobot-backend/…)api/validation_dashboard.pyapi/development_speedup.pyapi/system_validation.pyapi/code_search.pyapi/natural_language_search.pyapi/search.pyapi/analytics_llm_patterns.pyapi/analytics_pattern_learning.pyapi/error_resilience.pyapi/knowledge_eval.pyapi/phases.pyrouters/code_completion.pyrouters/feedback.pyrouters/model_management.pyphasesPOST/validation/runis admin-only, because it writes the same shared project state thatproject_statealready protects with admin.PhaseProgressionIndicator.vue,useDevSpeedup.ts,SystemRepository.ts,useLLMPatternData.ts) already send the bearer token. No service-to-service caller exists, so nothing broke.KNOWN_UNGATED/_MAX_KNOWN_UNGATEDwent from 16 to 2 (repo_tests/config_router_auth_coverage_test.py), under its equality rule.code_search_examples.py,analytics_llm_prompt_patterns.py,analytics_pattern_learning_records.pyanddev_speedup_analysis.py. Ceilings were lowered in both baselines.Verification
tests/api/test_router_auth_16375.pynow covers 21 routers and 94 routes, 14 of them admin:knowledge_evalgate removed, the anonymous test fails; the gate was then restored.router_auth_coverage,reach_scope_claim_17844, the size ratchet and the pre-push selection. The hook's pytest timed out (222s, loaded host), so the push usedAUTOBOT_PREPUSH_ALLOW_TIMEOUT=1after that run.Not done, stated rather than implied
api.prometheus_endpointandapi.rum: the last twoKNOWN_UNGATEDentries, waiting on the owner's ruling.api.codebase_analyticsandllc.apiare packages the guard's reader can't measure (UNREADABLE).So this PR is Refs #16375.
Refs #16375
Refs #18349
Model Used
Claude Opus 5.5 (master session: brief, PR). Implementation by a Claude Opus subagent.
🤖 Generated with Claude Code