BCH-1313: AuthZ Phase 1 — internal/authz (PDP, manifest, builtin driver) + single PEP#427
Conversation
gusfcarvalho
left a comment
There was a problem hiding this comment.
First-pass review (HEAD 7b44f85). Findings inline — non-blocking. Faithful zero-behavior-change admin migration; build/vet/gofmt and unit+integration tests pass with -race locally, CI green.
Headline: 1 Medium (admin action manage is enforced but absent from the manifest's declared admin vocabulary — inert in Phase 1 but a contract mismatch the next manifest-gating driver will hit) + 3 Low (admin path hardcodes the builtin driver and diverges from the config-selected evidence path; builtin's error→500 branch is untested; request ctx dropped on DB lookups). No blockers.
gusfcarvalho
left a comment
There was a problem hiding this comment.
LGTM — approving at HEAD 26882c5. All four findings from the review round are addressed and verified, and CI is fully green (check-diff, lint, unit-tests, integration-tests all pass).
- [Medium] admin action vocab —
manageadded to the admin resource's actions (granular*.managekept for later phases), thepdp.go"mirror the vocabulary" comment corrected, andHasAction(ResourceAdmin, ActionManage)now asserted inmanifest_test.go. ✅ - [Low] hardcoded builtin driver — comment documents the admin↔evidence divergence and the "route through authz.Open when a real second driver lands" plan. ✅
- [Low] untested error→500 branch —
TestBuiltinAdminGenuineDBErrorReturnsErrorforces a non-RecordNotFound DB failure and asserts error + deny, locking in 500-not-403. ✅ - [Low/nit] dropped ctx —
ctxthreaded throughevaluateAdmin; both admin DB lookups use.WithContext(ctx). ✅
Verified locally too: go build/vet/gofmt clean, unit + integration tests pass with -race (incl. the new DB-error case). Zero-behavior-change bar holds. Nice work.
|
PR approved. Marking ready for e2e. |
BCH-1313 — AuthZ Phase 1:
internal/authz(PDP interface, manifest loader, builtin driver)Implements Phase 1 of CCF Pluggable Authorization — Design Plan (BCH-1313).
Goal: centralize authorization behind one PEP + a pluggable PDP interface, with zero behavior change.
What's here
internal/authz— engine-neutralPDPinterface (Evaluate+ batchEvaluations),Subject/Resource/Decision/EvalRequesttypes, and a driver registry (Register/Open/Drivers) that mirrorsdatabase/sql.manifest.yamldeclares the authorization vocabulary (subjects, resources, actions, default roles); embedded viago:embedand parsed/validated at startup.builtindriver — reproduces today's rules: admin resources require SSO admin-group membership (password users are super admins; SSO-disabled or no-required-groups → allow); every other resource is allowed once authenticated. Self-registers and is the default.mw.Authorize(resource, action)PEP — builds the Subject from user/agent claims + route params, calls the PDP, and enforces: allow → next; deny →403(reason logged, never echoed); PDP-unavailable →fail_mode; other error →500.RequireAdminGroupsis now a thin PEP over the builtin driver (signature preserved; the rule's logic has a single home inauthz.Builtin). The evidence create route gainsAuthorize("evidence","create")after its existing authn middleware.authz.driver(defaultbuiltin) andauthz.fail_mode(defaultclosed), viaCCF_AUTHZ_DRIVER/CCF_AUTHZ_FAIL_MODE.Zero behavior change — verified
TestWorkflowImportRouteRequiresAdminGroup(admin-group denial) passes unchanged through the new PEP + builtin path.Authorizeon the create route.TestBuiltinAdminDecisionMatrix(sqlite,integration) covers the full admin decision matrix of the relocated logic; new unit tests cover the PEP status mapping / fail-mode and the manifest loader.go build ./...,go vet(incl.-tags integration), and the fullgo test ./...suite are green.Notes / scope
fail_modeis wired but inert forbuiltin(in-process, neverErrUnavailable); it governs the later remote drivers. Resource/subject attributes are intentionally minimal — the authoritative attribute surface is BCH-1319.ccf authz export, audit logging, and remote/cedar/permit drivers are later phases.🤖 Generated with Claude Code