[PM-40336] Access Rules: domain, persistence & schema - #7981
Conversation
|
Reviewed the automated code-quality suggestions. Decisions below: 1. 2. Dapper 3. 4. EF Net: keeping (1), (2), and (4) as-is by design; (3) is an optional cosmetic tweak. |
f5a81b6 to
74777a5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7981 +/- ##
===========================================
+ Coverage 14.99% 67.29% +52.30%
===========================================
Files 1409 2306 +897
Lines 61097 100426 +39329
Branches 4864 9028 +4164
===========================================
+ Hits 9161 67582 +58421
+ Misses 51780 30562 -21218
- Partials 156 2282 +2126 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the domain and persistence layer for org-scoped PAM Access Rules: the new Code Review Details
|
3c05d0f to
95d575b
Compare
d680dcf to
5b920b2
Compare
eliykat
left a comment
There was a problem hiding this comment.
Generally LGTM aside from the 1 question below.
The audit-event kinds, payload fields, and emitter doc referenced request, lease, credential, and system-control events that no action emits yet. Reduce AccessAuditEventKind to the rule group (RuleCreated/Updated/Deleted, 0-9) and AccessAuditEventData to the fields the rule commands set, keeping the emitter seam for the read side that lands later.
Wrap the EF delete (clear collection links, then remove the rule) in an explicit transaction so a partial delete cannot leave ungoverned collections. Read rule details via ReadFirstOrDefaultAsync and make the Dapper collection-mapping properties settable.
The audit-event kinds, phases, payload, and emitter seam were incomplete and need proper design before they can be relied on (notably a read-side pairing key). Drop AccessAuditEventKind, AccessAuditEventPhase, AccessAuditEventData, IAccessAuditEventEmitter, and NoopAccessAuditEventEmitter, and remove the comments that referenced those events. Audit will be reintroduced as its own piece of work.
Replace the per-directory PAM entries with one **/Pam* glob covering the Pam service, Pam.Domain, the Infrastructure Pam repos, and the PAM integration tests. Re-assert dept-dbops on src/Sql/dbo/Pam so PAM DB schema keeps its DBOps review, consistent with src/Sql/**.
…lder Collection sprocs stay together under the table's owning team (AC), per PR review.
The AccessRule migrations were generated on 2026-07-14, before the migrations that have since landed on main, so the chronological-order check fails. Re-date them to the end of the chain. The MSSQL script is a pure rename; its contents are unchanged and every statement is already guarded, so re-running it on a database that applied it under the old name is a no-op. The EF migrations are regenerated rather than renamed, so each provider's Designer snapshot targets the model as of its new position in the chain. The Up/Down bodies are byte-identical to the originals and DatabaseContextModelSnapshot is unchanged.
Infrastructure.Dapper and Infrastructure.EntityFramework now reference Pam.Domain directly, so every project that transitively depends on them (Api, Admin, Identity, the Pam service, tests, etc.) needs the reference recorded in its own lock file. Force-evaluated a full-solution restore to bring every lock file back in sync with the actual dependency graph.
Collection_SetAccessRuleAssociations is written as a collections sproc and its SSDT definition is already AdminConsole-owned, so keeping the method on IAccessRuleRepository split ownership: AC owned the MSSQL sproc while PAM owned the EF implementation. Both implementations now live on ICollectionRepository alongside the sproc they wrap. Addresses review feedback on #7981.
The access-rule commands now take ICollectionRepository for the collection association write, matching the method's new home after review feedback on #7981.
eliykat
left a comment
There was a problem hiding this comment.
Please add database integration tests for the new repository method.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-40336
📔 Objective
Add the domain and persistence layer for org-scoped PAM Access Rules — the
reusable policy objects that gate PAM credential leasing. This is the first of two
stacked PRs; the commercial CRUD API that consumes this layer follows in #7983
(stacked on this branch).
Access-rule data (name, description, conditions) is organization configuration
metadata, not Vault Data — no zero-knowledge surface is touched. Nothing here is
reachable at runtime until the API lands and the
pm-37044-pam-v-0(
FeatureFlagKeys.Pam) flag is enabled.What's included
Domain — new
Pam.Domainlibrary (src/Pam.Domain)AccessRuleentity: org-scoped rule with lease semantics —SingleActiveLease,DefaultLeaseDurationSeconds,MaxLeaseDurationSeconds,Enabled,AllowsExtensions/MaxExtensionDurationSeconds, andLastEditedBy.Conditionsstored as a JSONAccessConditiontree (validated in [PM-40336] Access Rules: API #7983).AccessRuleDetails(rule + governed collection IDs) andIAccessRuleRepository.Persistence
Infrastructure.Dapper) and EF Core (Infrastructure.EntityFramework)AccessRuleRepositoryimplementations, registered in DI.AccessRuletable + stored procedures (_Create,_Update,_DeleteById,_ReadById,_ReadByOrganizationId,_ReadDetailsById,_ReadDetailsByOrganizationId,Collection_SetAccessRuleAssociations).2026-07-14_01_AddAccessRule.sql) and EF migrations +snapshots for Postgres/MySQL/SQLite.
Collection association
Collection.AccessRuleIdFK (null = leasing disabled for that collection);updated
Collection_*stored procedures and theCollectiontable.(Touches AdminConsole-owned files — flagging for that team's review.)