Spaces:
Configuration error

Yash030 commited on
Commit
fce12d3
·
1 Parent(s): f672143

refactor: consolidate route auth + service accessors (closes #34)

Browse files

Delete the per-route _check_auth / _get_kv / _get_search_service /
_get_observation_store copies from observations, mcp, search, migration,
memories, graph, and health. Every protected handler now uses the
existing routes/auth.py:require_auth decorator; service accessors move
to a single routes/_deps.py that reads from Flask extensions with an
app-module-globals fallback for test resets.

Also registers kv on flask_app.extensions for symmetry with
observation_store and search_service.

New test tests/test_routes_auth_matrix.py walks every registered HTTP
rule and asserts the auth semantics (401 without token, 2xx with token,
2xx in no-secret mode, 401 on invalid token). Skips WebSocket routes
per the ticket.

Prep for #35 (legacy.py file-split) — removes the auth-plumbing churn
that would otherwise conflict across every route file.

10 files changed +252 -208
Files changed (10)
src/agentcache/app.py+1
src/agentcache/routes/_deps.pyAdded+46
src/agentcache/routes/graph.py+7-11
src/agentcache/routes/health.py+5-8
src/agentcache/routes/mcp.py+11-48
src/agentcache/routes/memories.py+8-11
src/agentcache/routes/migration.py+4-27
src/agentcache/routes/observations.py+11-57
src/agentcache/routes/search.py+8-46
tests/test_routes_auth_matrix.pyAdded+151