Resolve Document Access Through Nested Group Memberships
Last updated: November 29, 2026
Quick Overview
A document's ACL lists user and group ids. Given a user's direct groups and a map from each group to the groups it belongs to, decide whether the user can view the document, correctly handling deep nesting and membership cycles.
Glean
November 29, 20260
0
0 solved
A document's ACL lists user and group ids. Given a user's direct groups and a map from each group to the groups it belongs to, decide whether the user can view the document, correctly handling deep nesting and membership cycles.
Glean must never show a result a user cannot open in the source app, and identity providers like Google Workspace and Okta allow groups inside groups, sometimes with accidental cycles. The interviewer is looking for a graph traversal with a visited set, early exit, and a discussion of precomputing memberships for query-time speed.
What the Interviewer Expects
- Models groups as a directed graph and traverses with BFS or DFS
- Uses a visited set so cycles terminate
- Checks the user id itself as well as groups
- Exits early as soon as an allowed principal is found
- Discusses precomputing the transitive group closure per user for search-time filtering
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- At query time you need to filter 10,000 candidate documents. How do you avoid one traversal per document?
- A group gains a member. Which cached closures must be recomputed?
- How would you represent deny entries, and how do they interact with nested allow grants?
- How do you handle a source system that only exposes direct members of a group, with pagination and rate limits?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: user, doc_acl (list of principals), user_groups (user to direct groups), group_parents (group to groups that contain it). Output: True if the user, or any group reachable from the user...
High-Level Design
Turn the ACL into a set. Check the user id directly. Then BFS upward from the user's direct groups through group_parents, marking each group visited, and return True on the first group found in the ...