go
cr, err := client.Permission.LookupEntity(context.Background(), &v1.PermissionLookupEntityRequest{
TenantId: "t1",
Metadata: &v1.PermissionLookupEntityRequestMetadata{
SnapToken: "",
SchemaVersion: "",
Depth: 20,
},
EntityType: "document",
Permission: "edit",
Subject: &v1.Subject{
Type: "user",
Id: "1",
}
PageSize: 20,
ContinuousToken: "",
})client.permission.lookupEntity({
tenantId: "t1",
metadata: {
snapToken: "",
schemaVersion: "",
depth: 20
},
entity_type: "document",
permission: "edit",
subject: {
type: "user",
id: "1"
},
page_size: 20,
continuous_token: ""
}).then((response) => {
console.log(response.entity_ids)
})curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/permissions/lookup-entity' \
--header 'Content-Type: application/json' \
--data-raw '{
"metadata":{
"snap_token": "",
"schema_version": "",
"depth": 20
},
"entity_type": "document",
"permission": "edit",
"subject": {
"type":"user",
"id":"1"
},
"page_size": 20,
"continuous_token": "",
}'{
"entity_ids": [
"<string>"
],
"continuous_token": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Permission Service
Lookup Entity (Data Filtering)
POST
/
v1
/
tenants
/
{tenant_id}
/
permissions
/
lookup-entity
go
cr, err := client.Permission.LookupEntity(context.Background(), &v1.PermissionLookupEntityRequest{
TenantId: "t1",
Metadata: &v1.PermissionLookupEntityRequestMetadata{
SnapToken: "",
SchemaVersion: "",
Depth: 20,
},
EntityType: "document",
Permission: "edit",
Subject: &v1.Subject{
Type: "user",
Id: "1",
}
PageSize: 20,
ContinuousToken: "",
})client.permission.lookupEntity({
tenantId: "t1",
metadata: {
snapToken: "",
schemaVersion: "",
depth: 20
},
entity_type: "document",
permission: "edit",
subject: {
type: "user",
id: "1"
},
page_size: 20,
continuous_token: ""
}).then((response) => {
console.log(response.entity_ids)
})curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/permissions/lookup-entity' \
--header 'Content-Type: application/json' \
--data-raw '{
"metadata":{
"snap_token": "",
"schema_version": "",
"depth": 20
},
"entity_type": "document",
"permission": "edit",
"subject": {
"type":"user",
"id":"1"
},
"page_size": 20,
"continuous_token": "",
}'{
"entity_ids": [
"<string>"
],
"continuous_token": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Lookup Entity endpoint lets you ask questions in form of “Which resources can user:X do action Y?”. As a response of this you’ll get a entity results in a format of string array or as a streaming response depending on the endpoint you’re using.
So, we provide 2 separate endpoints for data filtering check request,
Lets say we called (reverse) lookup API to find the documents that user:1 can view. Permify first finds the relations that linked with view action, these are
- Lookup Entity
- Lookup Entity Streaming
How Lookup Operations Evaluated
We explicitly designed reverse lookup to be more performant with changing its evaluation pattern. We do not query all the documents in bulk to get response, instead of this Permify first finds the necessary relations with given subject and the permission/action in the API call. Then query these relations with the subject id this way we reduce lots of additional queries. To give an example,entity user {}
entity organization {
relation admin @user
}
entity container {
relation parent @organization
relation container_admin @user
action admin = parent.admin or container_admin
}
entity document {
relation container @container
relation viewer @user
relation owner @user
action view = viewer or owner or container.admin
}
document#viewerdocument#ownerorganization#admincontainer#``container_admin
user:1.Path Parameters
Body
application/json
PermissionLookupEntityRequest is the request message for the LookupEntity method in the Permission service.
Response
A successful response.