Permission improvements
Document permissions in Outline currently cascade downward: collection-level permissions grant access to all documents, and document-level permissions are copied to all children via sourceId tracking. Users can remove inherited permissions from child documents, but they reappear whenever the parent permissions change (because recreateSourcedMemberships() rebuilds them). There is no way to give a sub-document fewer permissions than its parent.
Users have requested the ability to lock down sub-documents so only explicitly granted members can access them, independent of collection or parent document permissions.
Design Decisions
- Framing: Not "restricted" but rather whether a document inherits permissions from its parent/collection. Users toggle inheritance on/off.
- Child behavior: Turning off inheritance propagates to all children (bulk write to descendants). This is necessary because hiding a parent from the sidebar would orphan its children.
- Sidebar visibility: Documents with inheritance off are hidden entirely from the sidebar for unauthorized users. Prune the subtree at that node.
- Admin access: Team admins bypass the restriction and can always access any document.
Plan
Approach: Single propagated column
Add one column to the documents table: isRestricted (BOOLEAN, default false).
When isRestricted = true:
- Collection-level permissions do not grant access to this document
- Parent document permission cascading (
sourceIdmemberships) is blocked - Only explicit (non-sourced) document-level memberships grant access
- Team admins still have access
Propagation model
- Restrict: Set
isRestricted = trueon the document + all descendants via bulk UPDATE - Unrestrict: Set
isRestricted = falseon the document + all descendants via bulk UPDATE - Queries: Simple
WHERE isRestricted = false- no recursive CTEs, no ancestor walks
Trade-off accepted: Unrestricting a parent also unrestricts children that may have been independently restricted. This is a rare edge case and the user can re-restrict specific children afterward. The simplicity gain (one column, simple queries, no derived state) is worth it.
Parent context in UI
When a document is restricted, the sharing panel checks the parent's isRestricted to show context:
- Document has
isRestricted = trueAND parent hasisRestricted = true→ "Access managed independently (set by [Parent Name])" - Document has
isRestricted = trueAND parent hasisRestricted = false(or no parent) → "Access managed independently" with toggle to turn off
This is a single parent lookup, not an ancestor chain walk.
Why cascading is necessary
Restriction MUST cascade to children because the sidebar hides restricted documents entirely. If a parent is restricted but its children are not, the children become orphaned in the tree. There is no good way to display them:
- Promoting children to the collection root loses hierarchy context
- Hiding children too is implicit cascading without the model to support it
- Showing a placeholder leaks that a restricted document exists
This mirrors the symmetry users expect: adding a permission cascades down, so removing inheritance should also cascade down.
Why this approach over alternatives
- Permission inheritance enum: Over-engineered. The need is binary.
- Explicit deny entries: Row explosion, order-dependent resolution, breaks the additive model.
- Two columns (
isRestricted+effectivelyRestricted): Adds denormalization that must be maintained on every tree mutation (restrict, unrestrict, move, delete). The single propagated column avoids this complexity. - Single column + ancestor walk: Correct but requires recursive CTEs in list/search queries.
Database Changes
Migration: add isRestricted to documents
Column: isRestricted
Type: BOOLEAN
Default: false
AllowNull: false
Index: yes (used in WHERE clauses for list/search filtering)Zero-downtime safe - Postgres adds a column with a default instantly, no table rewrite.
No changes to user_permissions or group_permissions tables.
Policy Layer Changes
File: server/policies/document.ts
Gate every collection-level fallback behind !document?.isRestricted. The pattern:
// Before (current):
can(actor, "readDocument", document?.collection)
// After:
and(!document?.isRestricted, can(actor, "readDocument", document?.collection))Updated read rule:
allow(User, "read", Document, (actor, document) =>
and(
isTeamModel(actor, document),
or(
includesMembership(document, [Read, ReadWrite, Admin]),
and(!!document?.isDraft, actor.id === document?.createdById),
isTeamAdmin(actor, document), // admins bypass restriction
and(!document?.isRestricted, can(actor, "readDocument", document?.collection))
)
)
);Rules requiring the gate (all rules that fall back to collection permissions):
read,update,move,restore,unarchive,manageUsers,duplicate,archive
New permission: "restrict" - who can toggle inheritance:
- Document Admin members
- Team admins
- Collection admins (when document is not already restricted)
- Draft creators
Cascading Logic Changes
UserMembership.recreateSourcedMemberships() / GroupMembership.recreateSourcedMemberships()
File: server/models/UserMembership.ts (line ~323)
File: server/models/GroupMembership.ts (line ~327)
Stop cascading at restricted document boundaries. When building the list of child document IDs via findAllChildDocumentIds, exclude documents where isRestricted = true and their entire subtree. Since restriction is propagated to children, any restricted child is a boundary - no need to check further descendants.
Document.publish() (line ~1042)
File: server/models/Document.ts
Skip parent membership copy for restricted documents:
if (this.parentDocumentId && !this.isRestricted) {
await GroupMembership.copy(...);
await UserMembership.copy(...);
}Restrict/Unrestrict Operations
When restricting a document:
authorize(actor, "restrict", document)- Set
isRestricted = trueon this document - Bulk UPDATE: set
isRestricted = trueon all descendants (usingfindAllChildDocumentIds) - Remove all sourced memberships on this document and descendants (memberships with
sourceId != null) - Auto-add the acting user as Admin document member if they don't already have direct membership
- Emit document update event for audit trail and real-time sync
When unrestricting a document:
authorize(actor, "restrict", document)(same permission for toggle)- Set
isRestricted = falseon this document - Bulk UPDATE: set
isRestricted = falseon all descendants - Re-inherit permissions from parent by rebuilding sourced memberships for this document and now-unrestricted descendants
- Emit document update event
Search & Listing Query Changes
server/models/helpers/SearchHelper.ts - buildWhere
Currently includes { collectionId: collectionIds } in the OR clause for collection-level access. Change to:
// Collection access only for non-restricted docs
{ [Op.and]: [{ collectionId: collectionIds }, { isRestricted: false }] }
// Direct/group membership still works regardless of restriction (already handled)documents.list endpoint
File: server/routes/api/documents/documents.ts
Add restriction filter. For non-admin users, restricted documents need membership verification:
WHERE (
("isRestricted" = false AND collectionId IN (:collectionIds))
OR ("isRestricted" = true AND (
EXISTS (SELECT 1 FROM user_permissions WHERE "documentId" = documents.id AND "userId" = :userId)
OR EXISTS (SELECT 1 FROM group_permissions gp
INNER JOIN group_users gu ON gu."groupId" = gp."groupId"
WHERE gp."documentId" = documents.id AND gu."userId" = :userId)
OR :isAdmin = true
))
)The EXISTS subqueries only execute for restricted documents (small minority), keeping performance impact minimal.
Document.findByIds post-filter
File: server/models/Document.ts
Gate collection-level access check behind !doc.isRestricted.
API Changes
Add isRestricted to documents.update schema
File: server/routes/api/documents/schema.ts
Add optional boolean field. The update handler checks authorize(actor, "restrict", document) before allowing the toggle, then runs the restrict/unrestrict operations described above.
Presenter changes
File: server/presenters/document.ts
Include isRestricted in the document response.
Shared Type Changes
File: shared/types.ts
Add isRestricted to NavigationNode so sidebar filtering can work.
Frontend Changes
Model
File: app/models/Document.ts
Add isRestricted: boolean observable field.
Sidebar - Hidden for unauthorized users
Restricted documents and their subtrees are pruned from the sidebar for unauthorized users. The collection's documentStructure (JSONB tree of NavigationNodes) is currently sent to all collection members.
Server-side filtering (recommended for security): Filter the documentStructure tree before sending to the client. Walk the tree, and for each node where isRestricted = true, check if the requesting user has direct membership. If not, remove the node and its entire subtree.
Implementation: when building the collection response, load the set of restricted document IDs in this collection where the user has a direct membership (SELECT documentId FROM user_permissions WHERE userId = :userId AND documentId IN (:restrictedDocIds) + equivalent for group memberships). Then walk the tree, keeping restricted nodes only if the user has membership.
Sharing Panel - Permission inheritance toggle
File: app/components/Sharing/Document/SharePopover.tsx or AccessControlList.tsx
Add a permission inheritance section at the top of the sharing panel:
- When
isRestricted = false: Show "Inherits access from [Collection Name]" or "Inherits access from [Parent Doc Name]" with a toggle/button to turn off inheritance - When
isRestricted = trueand set on THIS document (parent is not restricted): Show "Access managed independently" with toggle to re-enable inheritance - When
isRestricted = trueand parent is also restricted: Show "Access managed independently (set on [Parent Doc Name])" as informational context, with toggle still available to unrestrict this specific document
Show confirmation dialog when turning off inheritance: "This document and all its children will only be accessible to explicitly added members. Collection-level and inherited access will be revoked."
Lock/indicator in document header
When viewing a restricted document, show a visual indicator (lock icon or badge) in the document header so the user understands the access model differs from the default.
Edge Cases
| Scenario | Behavior |
|---|---|
| Restrict a doc with children | All descendants get isRestricted = true. Sourced memberships cleaned up on all. |
| Unrestrict a doc with children | All descendants get isRestricted = false. Sourced memberships rebuilt from parent chain. |
| Unrestrict a doc whose parent is restricted | Only this doc gets isRestricted = false. But since parent is restricted and this doc is hidden under it, effectively only matters if user navigates directly. |
| Move restricted doc under non-restricted parent | Stays restricted. Flag travels with document. |
| Move non-restricted doc under restricted parent | Does NOT automatically become restricted. The parent's restriction was propagated to its existing children when it was restricted, but a newly moved doc is not automatically affected. (Open question: should the move operation propagate? See below.) |
| Move non-restricted doc OUT of restricted parent | No change needed - doc wasn't restricted. |
| Publish child under restricted parent | Auto-set isRestricted = true on child (check parent state at publish time). No membership copy from parent. |
| Delete a restricted document | Normal deletion. Children are already restricted (flag was propagated), so no additional work needed. |
| Restore a deleted restricted document | Restore with isRestricted intact. |
Open question: Move into restricted subtree
When moving a non-restricted document under a restricted parent, should the moved document automatically become restricted? Two options:
- Yes (auto-restrict on move): Consistent with "children of restricted docs are restricted." Prevents accidental exposure.
- No (leave as-is): Simpler. User explicitly chose to move it there and can restrict it separately. But creates the orphan problem if this doc isn't hidden.
Recommendation: Auto-restrict on move into a restricted parent. This maintains the invariant that all children of a restricted document are restricted, which the sidebar pruning logic depends on.
Files to Modify
Backend:
server/models/Document.ts- addisRestrictedcolumn, modifypublish(),toNavigationNode,findByIdsserver/models/UserMembership.ts- modifyrecreateSourcedMembershipsto stop at restricted boundariesserver/models/GroupMembership.ts- same cascading changeserver/policies/document.ts- gate collection fallbacks behind!isRestricted, addrestrictpermission, add admin bypassserver/models/helpers/SearchHelper.ts- modifybuildWherefor restricted filteringserver/routes/api/documents/documents.ts- modify list query, handle restrict/unrestrict in update, filter documentStructure per userserver/routes/api/documents/schema.ts- addisRestrictedto update schemaserver/presenters/document.ts- includeisRestrictedserver/commands/documentMover.ts- auto-restrict when moving into restricted parent- New migration file
Shared:
shared/types.ts- addisRestrictedtoNavigationNode
Frontend:
app/models/Document.ts- addisRestrictedfieldapp/components/Sidebar/components/DocumentLink.tsxor parent component - filter restricted docs from treeapp/components/Sharing/Document/SharePopover.tsxorAccessControlList.tsx- permission inheritance toggle + context indicator- Document header component - lock/restricted indicator
Verification Plan
- Policy tests: Verify restricted docs block collection-level access, allow direct membership, allow admin override
- Cascade tests: Verify
recreateSourcedMembershipsstops at restricted boundaries - Propagation tests: Restrict parent → all descendants become restricted. Unrestrict → all descendants become unrestricted. Verify sourced membership cleanup/rebuild.
- API tests: Restrict/unrestrict via documents.update, verify bulk flag propagation
- Search tests: Verify restricted docs excluded from collection-based search results, included when user has direct membership
- Move tests: Move doc into restricted subtree → auto-restricted. Move out → stays restricted (flag on doc).
- Publish tests: Publish child under restricted parent → child auto-restricted, no membership copy.
- Sidebar tests: Verify restricted subtrees hidden from unauthorized users' document structure response.
- E2E: Create hierarchy A > B > C > D. Restrict B. Verify: A accessible to collection members, B/C/D only accessible to explicit members and admins. Add user to B explicitly. Verify they can see B but not C/D (unless also explicitly added). Unrestrict B. Verify C/D become accessible again.
Source: outline/outline