Skip to content

fix(security): add RBAC auth to 11 unauthenticated GET endpoints#367

Merged
robotlearning123 merged 2 commits intomainfrom
fix/documents-inventory-equipment-auth
Mar 29, 2026
Merged

fix(security): add RBAC auth to 11 unauthenticated GET endpoints#367
robotlearning123 merged 2 commits intomainfrom
fix/documents-inventory-equipment-auth

Conversation

@robotlearning123
Copy link
Copy Markdown
Member

Bug

11 GET endpoints across 3 route modules had zero authentication. Any unauthenticated user could read:

  • All documents (including OCR text, vendor names, extraction data)
  • All inventory items (quantities, locations, lot numbers, expiry dates)
  • All equipment records

Root Cause

router = APIRouter() had no router-level auth. POST/PATCH/DELETE had individual dependencies=[Depends(require_permission(...))], but GET endpoints were overlooked.

Fix

Added dependencies=[Depends(require_permission(...))] to all 11 endpoints:

Documents (view_documents):

  • GET / (list)
  • GET /stats
  • GET /{id}

Inventory (view_inventory):

  • GET / (list)
  • GET /low-stock
  • GET /expiring
  • GET /{id}
  • GET /{id}/history

Equipment (view_equipment):

  • GET / (list)
  • GET /{id}

All 3 permissions are in _VIEW_PERMS — every authenticated role has access.

Test

10 new tests in test_read_endpoints_auth.py verifying 401 on each endpoint when auth is enabled.

🤖 Found and fixed by bug-hunter autonomous loop.

@robotlearning123 robotlearning123 force-pushed the fix/documents-inventory-equipment-auth branch 2 times, most recently from 8ef4ca0 to 8ad7733 Compare March 28, 2026 21:46
@github-actions github-actions bot added the ci-verified All required CI checks have passed label Mar 28, 2026
@robotlearning123 robotlearning123 force-pushed the fix/documents-inventory-equipment-auth branch from 8ad7733 to 09cb405 Compare March 28, 2026 22:28
sandia777 and others added 2 commits March 28, 2026 18:42
…points

11 GET endpoints across 3 route modules had zero authentication:
- documents: GET /, GET /stats, GET /{id}
- inventory: GET /, GET /low-stock, GET /expiring, GET /{id}, GET /{id}/history
- equipment: GET /, GET /{id}

Any unauthenticated user could read all documents (including OCR text
and vendor data), inventory state, and equipment records.

Added view_documents, view_inventory, view_equipment permissions
respectively. All are in _VIEW_PERMS so every authenticated role has them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robotlearning123 robotlearning123 force-pushed the fix/documents-inventory-equipment-auth branch from 09cb405 to b5a4704 Compare March 28, 2026 22:42
@robotlearning123 robotlearning123 merged commit 8c39f57 into main Mar 29, 2026
22 checks passed
@robotlearning123 robotlearning123 deleted the fix/documents-inventory-equipment-auth branch March 29, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-verified All required CI checks have passed python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants