careful-honey-27437
04/17/2025, 1:00 AMbrief-egg-61061
04/17/2025, 1:00 AMbrief-egg-61061
04/17/2025, 1:01 AM# Get all groups for a user (e.g., Dilan) keto relation-tuple get --subject-id=Dilan --relation=member --format json --read-remote localhost:4466 # Then for each group, get permissions to objects keto relation-tuple get --subject-set="groups:marketing#member" --format json --read-remote localhost:4466
## Important Considerations 1. Subject Sets: The List API does not automatically expand subject sets. As noted in the [List API documentation](https://www.ory.sh/docs/keto/guides/list-api-display-objects#application-context): > "It's important to note that the list API does not expand subject sets. Usually the application has some context to determine what tuples to query anyway." 2. Application Context: Your application should have context about the structure of permissions to make efficient queries. For example, knowing the hierarchy of files and folders. 3. Alternative Approach: If you need to expand subject sets, you might need to use the [Expand API](https://www.ory.sh/docs/keto/guides/expand-api-display-who-has-access) instead, though this is typically used to show who has access to an object rather than what objects a user can access. For a file-sharing application with hierarchical permissions, you'll likely need to combine multiple queries to get a complete picture of what files a user can access, especially if you have complex permission inheritance through folders and groups.careful-honey-27437
04/17/2025, 1:04 AMbrief-egg-61061
04/17/2025, 1:04 AMbrief-egg-61061
04/17/2025, 1:04 AMdirectories
and files
namespaces respectively. They're identified by a UUID that the application maps to the actual object metadata." ## Implementation Flow: 1. Use the List API to get all relationship tuples where the user has access 2. Extract the object IDs (file IDs) from these tuples 3. Use these IDs to query your application database for the actual file data This approach aligns with best practices for integrating Ory Permissions into your application as described in the [integration guide](https://www.ory.sh/docs/keto/guides/simple-access-check-guide). ## Important Considerations: 1. Pagination: The List API returns paginated results, so you might need to handle multiple pages if the user has access to many files. As noted in the [List API documentation](https://www.ory.sh/docs/keto/guides/list-api-display-objects#pagination): > "The list API only returns paginated results... The response returns an opaque token that has to be used to retrieve the following page." 2. Don't Cache Permission Checks: While you'll be querying your database with the file IDs, remember not to cache the permission results themselves, as mentioned in the [best practices](https://www.ory.sh/docs/keto/guides/simple-access-check-guide#best-practices): > "Ory Network provides a low-latency, globally distributed system with appropriate caching... You don't need to worry about caching the permission checks in your application." 3. Batch Retrieval: If you need to retrieve a large number of identities or files, you might face limitations with the current API. There was a [GitHub issue](https://github.com/ory/network/issues/305) discussing the need for batch retrieval of identities, which suggests similar limitations might exist for other resources. This approach effectively separates your permission logic (handled by Ory) from your data storage, allowing you to maintain a clean architecture while still providing efficient access to resources.