Working with Access Control Lists (ACL)

1. Understanding ACL Concepts

ConceptDetail
DefinitionList of (principal, permission) entries attached to a resource
GranularityPer-object — fine-grained
Best forDocument sharing, file systems
Vs RBACACL = object-centric; RBAC = role-centric

2. Defining ACL Entries

Example: ACL row

CREATE TABLE acls (
  resource_type TEXT, resource_id BIGINT,
  principal_type TEXT,        -- "user" | "group"
  principal_id BIGINT,
  permission TEXT,            -- "read" | "write" | "delete" | "share"
  granted_at TIMESTAMPTZ,
  PRIMARY KEY (resource_type, resource_id, principal_type, principal_id, permission)
);

3. Implementing Object-Level Permissions

OperationDetail
GrantINSERT ACE
RevokeDELETE ACE
CheckLookup (resource, principal, permission) — index for O(1)
List sharesWHERE resource_id matches

4. Setting File System ACLs

SystemTool
POSIXsetfacl -m u:alice:rwx file
NFSv4Detailed ACEs, inheritance flags
Windows NTFSicacls
S3Bucket policies preferred over object ACLs

5. Implementing Discretionary ACL

AspectDAC
Owner controlsResource owner grants/revokes access
ExampleGoogle Docs sharing
RiskOwner can over-share

6. Implementing Mandatory ACL

AspectMAC
Policy set bySystem / security admin
Owner can change?No
ExampleSELinux, military classification (Bell-LaPadula)
UseHigh-security environments

7. Using ACL Inheritance

ConceptDetail
Inheritance flagChildren inherit parent's ACEs
OverrideChild can add explicit ACEs that supersede
PropagationOn parent change, recompute or store materialized path
Tree modelFolder → file inheritance (Drive, S3 prefix)

8. Checking ACL Permissions

Example: Check with group expansion

SELECT 1 FROM acls
WHERE resource_type='doc' AND resource_id=$1 AND permission=$2
  AND ((principal_type='user' AND principal_id=$3)
   OR  (principal_type='group' AND principal_id IN (
        SELECT group_id FROM user_groups WHERE user_id=$3)))
LIMIT 1;

9. Implementing ACL Precedence Rules

RuleOrder
Explicit denyHighest priority (overrides allow)
Explicit allowNext
Inherited denyLower
Inherited allowLower
DefaultDeny

10. Managing ACL Performance

OptimizationDetail
Indexing(resource_id, principal_id, permission)
Materialized viewsExpanded user→permissions per resource
CachingDecision cache with invalidation on grant change
ShardingBy resource_id or tenant
Zanzibar-styleGoogle's relationship graph for billions of objects