LoonFS supports granular permissions on individual files and folders.
Every request that reads or changes namespace contents chooses its authority explicitly. Send Loonfs-Principals to enforce file and folder permissions, or Loonfs-Context: service for a trusted application request with the deployment token’s full authority. There is no permanent namespace access mode.
Understanding permissions
Section titled “Understanding permissions”A permission grant connects a principal to a set of privileges. A principal is an application layer ID, such as a user ID or a group ID. LoonFS does not manage group membership; the application backend sends the applicable principal IDs with each request.
| Privilege | On a folder | On a file |
|---|---|---|
read | List entries and read attributes. | Read contents and attributes. |
history | Read previous folder contents through a snapshot. (Requires read too.) | Read previous revisions and revision history. (Requires read too.) |
write | Update attributes. | Update contents or attributes. Restoring an earlier revision also requires history. |
create | Add files and folders, including moving an item into the folder. | Not applicable. (Permission for creating a file is granted using create on the parent folder.) |
remove | Delete entries or move them out of the folder. | Not applicable. (Permission for deleting a file is granted using remove on the parent folder.) |
share | Add or remove grants for permissions already granted to the actor. | Same as folders. |
manage | Change grants and whether the folder inherits permissions. Cannot grant or remove admin. | Change grants, except admin. |
admin | Full access to the namespace. (Can only be granted on the root folder.) | Not applicable. |
For example, editing a file requires write on the file, while deleting it requires remove on its parent folder.
Building roles in the application layer
Section titled “Building roles in the application layer”LoonFS stores permissions, not role names. Applications may wish to combine permissions into familiar roles:
| Example role | Permissions |
|---|---|
| Upload-only | create |
| Viewer | read |
| Viewer with history | read, history |
| Editor | read, history, write, create, remove |
| Manager | read, history, write, create, remove, share, manage |
| Administrator | admin on the root folder |
These are examples, not built-in roles. For instance, applications may wish to add the share permission to the Editor role if editors should be able to invite other users.
Inheriting permissions
Section titled “Inheriting permissions”A grant on a folder applies to its files and subfolders. If a user has access through several principals, those permissions are combined.
Set boundary: true on a folder to stop it from inheriting grants from its parents. The folder’s own grants still apply to its contents. For example, a restricted /finance folder can stop inheriting the access granted to everyone at /.
There are no explicit deny rules. Namespace administrators can access every file and folder, including folders with an inheritance boundary.
Setting initial permissions
Section titled “Setting initial permissions”Create a namespace with Create namespace and the required Loonfs-Actor header:
{ "namespace_id": "team-files"}Then submit a commit in service context to set its first administrator. Include Loonfs-Actor: user_123 and Loonfs-Context: service with this body:
{ "commit_id": "initialize-team-permissions", "operations": [ { "kind": "update_access", "path": "/", "boundary": false, "grants": { "user_123": ["admin"] } } ]}This grants user_123 administrator rights on the root folder. Service context can update grants in any namespace, including restoring access when no administrator remains.
Making requests for a user
Section titled “Making requests for a user”Alongside the bearer token, send the principals whose combined grants should authorize the request:
Loonfs-Actor: user_123Loonfs-Principals: user_123,team_designThis request uses grants for user_123 and team_design. The actor identifies the caller for commit attribution and upload ownership; it does not determine the request’s permissions. Use stable internal IDs, not email addresses or display names. Principal IDs must be separated with commas and no spaces.
Loonfs-Actor is required for commits, namespace creation and forking, and every upload operation. It is not required for ordinary reads. Applications must authenticate users and supply their principals before forwarding requests to LoonFS.
Making requests as the application
Section titled “Making requests as the application”For trusted work such as indexing, migrations, or an application without per-user permissions, send:
Loonfs-Actor: document-importerLoonfs-Context: serviceService context bypasses per-user permission checks. Do not let an untrusted client choose it. A namespace-content request must send exactly one of Loonfs-Principals and Loonfs-Context; sending neither or both returns invalid_request. Capability discovery, namespace metadata reads, and namespace creation do not read these context headers.
The API reference’s curl examples use service context. Replace it with Loonfs-Principals when acting for a user.
Changing a folder’s permissions
Section titled “Changing a folder’s permissions”For example, to let the design team edit an existing /design folder, POST a commit with this operation:
{ "kind": "update_access", "path": "/design", "boundary": false, "grants": { "team_design": ["read", "history", "write", "create", "remove"] }}update_access replaces the item’s direct grants, so include any existing grants you want to keep. Setting boundary: false ensures grants from parent folders still apply.
To avoid overwriting another permission change, include expected_inode_id and expected_access_revision_no from the item’s current entry.
A few useful details
Section titled “A few useful details”- Reading a folder’s children can reveal the names of children that the user cannot open. Reading those files still requires permission on each file.
- Moving a file can change its inherited permissions. Moves that grant new access require permission to share that access.
- Snapshot and revision reads use the user’s current permissions. An old snapshot does not restore permissions that were removed.
- Deleting a folder checks
removeon its parent, even if the folder contains restricted subfolders.