<@U04UQ68083H> Using the ory permission model, hav...
# ory-copilot
p
@chilly-king-10285 Using the ory permission model, having a User, Folder and File namespace, where a User can have view and edit permission to files and folders and the edit/view permission for files traverses the parent folder to check the according permission. How can I get all files a user has access to? How can I get all files, that match a permit from the permission model?
c
A message from kapa.ai
To get all files a user has access to, you can use the List API provided by Ory. This API allows you to display all objects a user has access to. However, the specific implementation details or code examples are not provided in the given knowledge sources. To get all files that match a permit from the permission model, you would typically perform a permission check for each file. In Ory, you perform an action on behalf of a user by checking for a specific permission, such as
view
or
edit
. The concrete permission is then still checked against the relationships. For example, if
owners
can
view
a file and the
view
permission is checked, then the
owners
relation is looked up in the relationships database. Here's an example of how you might check permissions for a document: -
view
a document if the user is a
viewer
,
editor
, or
owner
of the document; or if the user can
view
the parent folder -
edit
a document if the user is a
editor
, or
owner
of the document; or if the user can
edit
the parent folder Again, the specific implementation details or code examples for this process are not provided in the given knowledge sources. For more detailed information, you may want to refer to the following resources: - [Ory Keto Documentation](https://www.ory.sh/docs/keto) - [How to integrate permission checks to your application](https://www.ory.sh/docs/keto/guides/simple-access-check-guide#understand-ory-permissions) - [List API: Display all Objects a User has Access to](https://www.ory.sh/docs/keto/guides/list-api-display-objects)
p
is there a way to do that without having to create a speparate check for each file
@chilly-king-10285 is there a way to do that without having to create a separate check for each file?
c
A message from kapa.ai
Based on the provided knowledge sources, there isn't a direct way to get all files a user has access to without checking each file individually. The Ory Keto system is designed to perform permission checks on individual actions, such as viewing or editing a file. However, you could potentially optimize this process by structuring your permissions and relationships in a way that allows you to infer access to multiple files based on a single permission check. For example, if a user has view access to a folder, you could infer that they have view access to all files within that folder. Remember, it's important to perform permission checks in every critical path of the application. Anytime an action is taken that requires a permission check, make sure to perform that check using Ory Permissions. This includes creating, reading, updating, and deleting resources ([source](https://www.ory.sh/docs/keto/guides/simple-access-check-guide#best-practices)). For more detailed information on how to structure your permissions and relationships, you may want to refer to the [Ory Keto Documentation](https://www.ory.sh/docs/keto) and the [Permission Model Guide](https://www.ory.sh/docs/keto/modeling/create-permission-model).