fix(auth): requerir rol admin en rutas de agentes, rearme y gestión de routers - #8
Merged
Conversation
…e routers Auditoría v2.4.0 §2 (issue #7): las rutas que mutan la monitorización o exponen credenciales estaban tras RequireAuth (cualquier sesión), no tras RequireAdmin. Un usuario con rol 'user' podía crear/revocar tokens de agente, rearmar agentes vía SSH, añadir/borrar routers y ver la clave SSH pública del servidor. Backend (server-go): - POST/DELETE /api/agents, POST /api/agents/{slug}/rearm → RequireAdmin - POST/DELETE /api/config/routers, GET /api/config/sshkey, GET /api/config/discover → RequireAdmin - Lecturas equivalentes (GET /api/agents, GET /api/config/routers) siguen tras RequireAuth; sin cambio de contrato para admin. Frontend (app): - RoutersManager se oculta a usuarios no admin (Settings). - Botón «Rearmar» solo con rol admin (AgentRearmButton). Tests: admin_gate_test.go — 403 para rol user en las rutas mutantes y de credenciales; 200 en las lecturas; 201 para admin en POST /api/agents. Suite completa verde + go vet + tsc. Bump v2.4.1. Fixes #7
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.
Cierra el punto §2 (permisos demasiado amplios) de la auditoría de seguridad v2.4.0.
Problema: crear/revocar agentes, rearmar agentes vía SSH, añadir/borrar routers, ver la clave SSH pública y escanear la LAN solo exigían sesión (RequireAuth), no rol admin. Un usuario de rol
userpodía modificar la monitorización o ejecutar acciones sobre los routers.Fix:
POST/DELETE /api/agents,POST /api/agents/{slug}/rearm,POST/DELETE /api/config/routers,GET /api/config/sshkey,GET /api/config/discover→RequireAdmin(403 para rol user). Lecturas equivalentes siguen trasRequireAuth.RoutersManagery botón «Rearmar» solo visibles para admin.admin_gate_test.go(403 user / 200 lecturas / 201 admin). Suite completa verde + vet + tsc.Fixes #7. Relacionado con #6 (issue paraguas de la auditoría).