Commit Graph
11 Commits
Author SHA1 Message Date
YueGuobin 2244d730bb perf: keep RBAC state in memory for permission checks
Permission checks ran several queries per request, including a full
scan of the resources table. The controller already keeps projects,
computes and notifications in process memory: apply the same idea to
the RBAC tables.

Roles, ACEs, group memberships and resource pool memberships are
loaded into a process-wide snapshot. Checks run against the snapshot
in memory. Repository write methods mark the snapshot dirty and the
next read reloads it from the database, so privilege changes apply
right away. The database stays the source of truth.

The evaluation is a faithful port of the previous SQL version, quirks
included (reverse path traversal, deny raising PermissionError, pool
checks with the "/pool" prefix, group ACEs in natural order).

The two RBAC tests that mutated ORM objects directly now write through
the repository, like the rest of the code. The /projects ACE they
relied on was created by another test, so they were order dependent:
they now create it when missing.
2026-11-06 23:47:29 +08:00
YueGuobin 70ef92b55f fix: keep legacy projects visible to non-admin users
Projects created before GNS3 3.1 have no created_by field. The project
list filtered them out for every non-superadmin user, so all old
projects disappeared from the list after an upgrade.

Fall back to the pre-3.1 ACE-only visibility rule when created_by is
not set. Projects owned by another user stay hidden.
2026-11-05 15:42:51 +08:00
Mark Paronyan 306d8fbde4 refactor: remove unused imports 2026-10-03 19:43:58 +03:00
Mark Paronyan 6d16d923c7 style: sort imports in compute and controller tests 2026-10-02 12:43:26 +03:00
Mark Paronyan a0450b6bce refactor: ruff autofixes 2026-09-27 15:55:10 +03:00
YueGuobin 9825a7b271 test: fix RBAC test to match implementation logic
- Update test_list_projects_in_resource_pool to use independent AsyncClient
- Fix test logic to match actual RBAC implementation:
  - Direct ACE + created_by match = accessible
  - Resource pool ACE = accessible (no created_by check)
  - Deduplication prevents duplicate projects
- Test now verifies: pool-only access → pool + /projects access → /projects-only access
- Add missing imports for ASGIWebSocketTransport and auth_service
2026-05-28 00:02:25 +08:00
YueGuobin e6581dfe68 test: update RBAC test to use test_user.username for user isolation
Updated test_list_projects_in_resource_pool to:
- Add test_user fixture parameter
- Use test_user.username when creating projects to match created_by filtering
- Switch from authorized_client to client (admin user) for consistency

This aligns the test with the new user isolation architecture where
projects are filtered by created_by == current_user.username.

Note: This test currently fails with 401 due to test infrastructure
JWT authentication issues, but the core RBAC functionality is verified
by TestPrivileges (13 tests passing).
2026-05-26 23:46:28 +08:00
grossmj a95dda0d1d Complete resource pool support for projects 2023-09-11 18:15:03 +07:00
grossmj 0077fd98aa Add required privileges to all endpoints 2023-09-02 17:54:24 +07:00
grossmj 60ce1172e0 Use an ACL table to check for privileges 2023-08-27 18:20:42 +10:00
grossmj d65b49acaa Add user permissions + RBAC tests. 2021-06-03 15:40:12 +09:30