Fix accounts mailbox owner auth boundary - #300
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR enforces an authorization boundary on mailbox config endpoints by rejecting system/platform admin JWT roles before credential access. It implements an early-stage guard in the API, shifts account config tests toward signed session validation (away from dev header overrides), and documents the policy constraint and implementation plan. ChangesMailbox Account Owner Authorization Boundary
Sequence DiagramsequenceDiagram
participant TestClient
participant GetTenantConfig
participant EnsureMailboxOwner
participant MockDatabase
rect rgba(255, 100, 100, 0.5)
Note over TestClient,GetTenantConfig: System Admin Rejection Path
TestClient->>GetTenantConfig: GET /api/accounts/config<br/>(system_admin signed token)
GetTenantConfig->>EnsureMailboxOwner: check auth role
EnsureMailboxOwner-->>TestClient: 403 Forbidden
Note over MockDatabase: No DB execution
end
rect rgba(100, 255, 100, 0.5)
Note over TestClient,GetTenantConfig: Scoped Member Acceptance Path
TestClient->>GetTenantConfig: GET /api/accounts/config<br/>(member signed token)
GetTenantConfig->>EnsureMailboxOwner: check auth role
EnsureMailboxOwner->>MockDatabase: fetch/create config
MockDatabase-->>GetTenantConfig: config record
GetTenantConfig-->>TestClient: 200 with config
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
system_adminandplatform_adminsigned sessions on/api/accounts/configbefore mailbox/provider credential lookup.AGENTS.mdand add the phase plan document.Verification
PYTHONDONTWRITEBYTECODE=1 python3 -m pytest backend/tests/test_accounts_api.py backend/tests/test_auth_real.py backend/tests/test_tenant_config_api.py -q→ 69 passed, 1 skippedPYTHONDONTWRITEBYTECODE=1 python3 -m bandit -r backend/ -x backend/tests/ -q→ passedPYTHONDONTWRITEBYTECODE=1 python3 -m pytest -qfrombackend/→ 508 passed, 13 skippedgit diff --check→ passedNotes
Summary by CodeRabbit