careful-honey-27437
06/09/2025, 1:48 AMbrief-egg-61061
06/09/2025, 1:48 AMbrief-egg-61061
06/09/2025, 1:48 AM/photos/beach.jpg
in the files
namespace, specifically for the access
relation. ### Using the Keto CLI You can use the following command: keto expand access files /photos/beach.jpg
This will output a tree showing all subjects (users or groups) who have access, either directly or indirectly, to the file. For example, the output might look like: ∪ files:/photos/beach.jpg#access ├─ ∪ files:/photos/beach.jpg#owner │ ├─ ☘ maureen ├─ ∪ directories:/photos#access │ ├─ ☘ laura
This means: - maureen
has access because she is the owner. - laura
has access because she was granted access to the parent directory. ### Using the REST API You can also use the REST API: GET /relation-tuples/expand?namespace=files&object=/photos/beach.jpg&relation=access
This will return a JSON tree structure with all the subjects who have access, including the reason (direct or via group/parent). ### Notes - The expand API returns a tree, not just a flat list, so you may need to traverse the tree to extract all subject IDs. - You can limit the depth of the expansion using the max-depth
parameter to control performance and output size. For more details and examples, see the official documentation: [Expand API: display who has access to an object](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#example) and [Keto CLI expand command](https://www.ory.sh/docs/keto/cli/keto-expand#keto-expand).careful-honey-27437
06/09/2025, 1:52 AMcareful-honey-27437
06/09/2025, 1:52 AMbrief-egg-61061
06/09/2025, 1:52 AMbrief-egg-61061
06/09/2025, 1:52 AMupdate
access to an article object called art_123
, based on your described permission model. ### 1. Using the Expand API You would call the expand API for the update
relation on the Articles
namespace and the object art_123
. For example, using the Keto CLI: keto expand update Articles art_123
Or, using the REST API: GET /relation-tuples/expand?namespace=Articles&object=art_123&relation=update
### 2. What the Expansion Tree Shows The expand API will return a tree structure that includes all users (subject IDs) who have update
access to art_123
, either directly (e.g., as article editors, admins, collaborators) or indirectly (e.g., via publication or organization roles, if your permission model is set up accordingly). The output will look similar to this (the actual structure depends on your namespace and relation configuration): ∪ Articles:art_123#update ├─ ∪ Articles:art_123#admin │ ├─ ☘ user_alice ├─ ∪ Articles:art_123#editor │ ├─ ☘ user_bob ├─ ∪ Articles:art_123#collaborator │ ├─ ☘ user_charlie ├─ ∪ Publications:pub_456#admin │ ├─ ☘ user_dana ├─ ∪ Publications:pub_456#editor │ ├─ ☘ user_erin ├─ ∪ Organizations:org_789#admin │ ├─ ☘ user_frank ├─ ∪ Organizations:org_789#owner │ ├─ ☘ user_grace
Each ☘️ leaf node is a subject ID (user) who has update
access, either directly or through a higher-level role. ### 3. Notes - The actual users and structure depend on your relationship tuples and namespace configuration. - You may need to traverse the returned tree to extract all subject IDs programmatically. - The expand API is designed to show not just who has access, but also why (through which relation or inheritance) [Expand API: display who has access to an object](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#example). - You can limit the depth of the expansion with the max-depth
parameter if needed [Maximum tree depth](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#maximum-tree-depth). For more details, see the [Keto CLI expand command documentation](https://www.ory.sh/docs/keto/cli/keto-expand#keto-expand) and the [Expand API guide](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#example).careful-honey-27437
06/09/2025, 1:54 AMbrief-egg-61061
06/09/2025, 1:54 AMbrief-egg-61061
06/09/2025, 1:54 AMupdate
access to an article object called art_123
, you would use the expand API on the update
relation for the Article
namespace and the object art_123
. ### How to Use the Expand API #### Using the Keto CLI sh keto expand update Article art_123
#### Using the REST API GET /relation-tuples/expand?namespace=Article&object=art_123&relation=update
### What the Expand API Returns The expand API will return a tree structure that includes all users who have update
access to art_123
, either directly (as editors or collaborators) or indirectly (via publication or organization roles, as defined in your OPL). You will need to traverse the tree to extract all subject IDs. The tree will reflect the logic in your OPL, which for Article.update
is: - Direct: editors
and collaborators
of the article. - Indirect: Any user who has update
access via the related Publication
(which itself may include users with admin
or editor
roles, or those with access via the related Organization
). The expand API is specifically designed to show all effective subjects and the reason for their access, matching your use case perfectly. You may use the max-depth
parameter to control how deep the tree is expanded if you want to limit indirect relationships for performance or clarity reasons [Expand API: display who has access to an object](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#example) [Maximum tree depth](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#maximum-tree-depth). Note: The actual list of subject IDs will depend on your stored relation tuples and the relationships between articles, publications, organizations, and users in your system. For more details, see the [Expand API documentation](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access#example).careful-honey-27437
06/09/2025, 1:57 AMGET /relation-tuples/expand?namespace=Articomes cle&object=art_123&relation=update
it replies with {"code":404,"status":"Not Found","message":"no relation tuple found"}
. It only “works” when I format the request to check a direct relation (like “editors”, not a permit associated with a relation like “update”.brief-egg-61061
06/09/2025, 1:57 AMbrief-egg-61061
06/09/2025, 1:57 AMeditors
, admins
, or similar. The API expects a relation that is directly stored as a relation tuple, not a computed permission (permit) like update
that is defined in OPL and may be composed of multiple underlying relations or traversals. This is confirmed in the documentation, which states: > The expand-API allows to expand a given subject set into all its effective subjects. > — [Expand API: display who has access to an object](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access) And the API reference shows the parameters as namespace
, object
, and `relation`—where relation
must be a direct relation tuple, not a computed permission: > Use this endpoint to expand a relationship tuple into permissions. > — [Keto REST API Reference: expandPermissions](https://www.ory.sh/docs/keto/reference/rest-api#expandpermissions) If you try to expand a computed permission (like update
), and there is no direct relation tuple stored for that permission, the API will return a 404 Not Found, as you observed. In summary: The expand API only works for direct relations (e.g., editors
, admins
) that are stored as relation tuples. It does not expand computed permissions (permits) like update
that are defined in OPL and may aggregate multiple relations. This is a current limitation of the expand API as described in the official documentation. If you need to see all users with a computed permission like update
, you would need to manually expand all the underlying relations (e.g., editors
, collaborators
, and traverse up to publication and organization roles) using multiple expand or list queries, or by evaluating the OPL logic in your application code. If you need further details, please refer to the [Expand API guide](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access) and the [REST API reference](https://www.ory.sh/docs/keto/reference/rest-api#expandpermissions).