fix(security): restrict logic graph mutations to admin users#63
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac4150c16c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| async def create_graph( | ||
| body: LogicGraphCreate, | ||
| _user: str = Depends(get_current_user), | ||
| _user: str = Depends(get_admin_user), |
There was a problem hiding this comment.
Allow admin API keys on graph mutation routes
Switching these endpoints to Depends(get_admin_user) breaks all API-key based automation: get_current_user resolves API keys to api_keys.name (not the owning username), and get_admin_user then checks users.username = current_user, which returns no row and raises 403 for every API key request. This means even keys owned by admin users can no longer create/update/delete/import/duplicate graphs, which is a regression for script-driven management workflows.
Useful? React with 👍 / 👎.
|
Danke für den Security-Fix. Kurze Einordnung zu Risiken/Folgen, damit wir die offene Berechtigungsentscheidung im Team sauber treffen: Was dieser PR konkret verbessert
Was weiterhin bewusst offen bleibt (und Security-relevant ist)
Folgen für den Betrieb
Offene Architekturfrage (Team-Entscheidung)
Empfohlene nächste Schritte (unabhängig von der Grundsatzentscheidung)
|
Motivation
timer_cronnodes from stored graphs, and graph creation/update was previously permitted for any authenticated user, enabling low-privilege actors to persist scheduled background tasks and unattended datapoint writes.Description
get_admin_userand require it instead ofget_current_userinobs/api/v1/logic.py.create_graph,update_graph_full,update_graph_partial,delete_graph,import_graph, andduplicate_graphto useDepends(get_admin_user)so only admin users can persist or modify graphs.list_graphs,get_graph,export_graph,run_graph) asget_current_userto keep non-persistent operations available to authenticated users.obs/logic/manager.py) or execution paths beyond this authorization boundary.Testing
python -m compileall obs/api/v1/logic.pysucceeded for the modified file.tests/unit/test_logic_rename.pyand integration suites) failed in this environment because thepytest-asyncioplugin is not installed, so async tests could not be executed here.Codex Task