You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wire ACL metadata into database open, create, finish, and backup
Summary:
# What has changed
Integrates ACL metadata loading and ACL-aware query slicing into the database
lifecycle (Open, Create, Finish, Backup):
- **Open.hs** (236 net new lines): Loads firstACLID and ACL group mapping from
DB metadata at open time, populating new OpenDB fields (odbACLMode,
odbACLMapping, odbFirstACLID). Adds ACL-aware query slicing via
buildLayerACLSlice and withStackedACLSlices, which construct ownership
slices that include ownership units + matched ACL groups. The
readDatabaseWithBoundaries and withOpenDBLookup APIs gain an [Text] ACL
group names parameter.
- **Create.hs** (28 net new lines): Inherits base DB's firstACLID and ACL
group mapping for incremental/stacked databases. Propagates the inherited
GUID through the Storage.Create constructor (now 4-arg). Logs ACL mode at
create time.
- **Finish.hs** (7 new lines): Reads and logs ACL mode from database
properties at finalization time for debugging.
- **Backup.hs** (1 new line): Adds import for ACL-related types.
# Why the change?
For ACL filtering to work at query time, the server must load ACL metadata
(firstACLID boundary, group→UsetId mapping) when opening a database, and
construct appropriate ownership slices that restrict query results to facts
matching the caller's ACL groups. For stacked/incremental DBs, ACL metadata
must be inherited from the base DB to maintain consistent ACL ID assignments
across the stack. The Create and Finish changes ensure ACL state is properly
logged and propagated through the DB lifecycle.
# Most important changes
- `buildLayerACLSlice` in Open.hs (lines 270-380): Core ACL slice construction.
Resolves ALL ACL group UnitIds via Storage.getUnitId, checks if they fall
within the ownership range, and builds a combined slice of ownership units +
matched ACL groups. Handles stacked namespace mismatch by falling back to
firstACLID boundary. Risk: resolves every ACL group name on every query —
could be expensive with many groups.
- `withOpenDBLookup` refactored in Open.hs (lines 160-230): Now handles 4
cases: (no slicing, base-only, top-only, both). Each case constructs a
different sliced/stacked lookup chain. Risk: complex nesting of
withCanLookup callbacks — hard to verify correctness.
- `withStackedACLSlices` in Open.hs (lines 390-410): Recursive walk of DB
stack building ACL slices per layer. Risk: unbounded recursion on deep
stacks.
- OpenDB field population in Open.hs (lines 723-745): Loads firstACLID and
ACL group mapping after OpenDB creation, then replaces the OpenDB with
updated fields. Uses parseACLGroupMappingJson from Data.hs.
- `readDatabaseWithBoundaries` signature change (lines 254-265): New [Text]
parameter is a breaking API change — all callers must be updated.
- `setupSchema` pattern match change (line 491): Create constructor now takes
4 arguments (added GUID parameter from commit 8).
Simplify withStackedACLLookup and move ACL slice construction to exclude-mode semantics in Open.hs (folds in withStackedACLLookup simplification, formerly D108629297).
Reviewed By: CatherineGasnier
Differential Revision: D97111663
fbshipit-source-id: 6da8ebd37c0d89965df6c2a635cd15501f131333
0 commit comments