full-midnight-13013
06/13/2023, 6:52 AM❯ ory is allowed User:David view ContentItem Recept1
Allowed
The REST API (not working as expected):
❯ curl --location 'https://[APIENDPOINT]/relation-tuples/check/openapi?namespace=ContentItem&object=Recept1&relation=view&subject_id=User%3ADavid' \
--header 'Authorization: Bearer [APITOKEN]'
{"allowed":false}
What part am I overlooking?full-midnight-13013
06/13/2023, 8:03 AM❯ ory list relationships
NAMESPACE OBJECT RELATION NAME SUBJECT
Organization Plate admins User:David
ContentItem Recept2 owner Organization:Gr
ContentItem Recept1 owner Organization:Plate
full-midnight-13013
06/13/2023, 8:04 AMimport { Namespace, SubjectSet, Context } from "@ory/permission-namespace-types"
class Organization implements Namespace {
related: {
admins: User[],
contentEditors: User[]
}
}
class User implements Namespace {
}
class ContentItem implements Namespace {
related: {
owner: Organization[]
}
permits = {
view: (ctx: Context): boolean =>
this.related.owner.traverse((p) => p.related.admins.includes(ctx.subject)) ||
this.related.owner.traverse((p) => p.related.contentEditors.includes(ctx.subject))
}
}
full-diamond-56778
06/13/2023, 2:14 PMsubject_namespace
and subject_object
, not subject_id
. I’m using also the js client and only that works for me.full-diamond-56778
06/13/2023, 2:14 PMsubject_relation
as empty string (if you will see error that given parameters aren’t supported).full-midnight-13013
06/13/2023, 2:21 PMcurl --location '<https://XXXX/relation-tuples/check/openapi?namespace=ContentItem&object=Recept1&relation=view&subject_namespace=User&subject_id=David>' \
--header 'Authorization: Bearer XXXX'
Still returns allowed: false sadly.full-diamond-56778
06/13/2023, 2:21 PMsubject_object
not subject_id
full-diamond-56778
06/13/2023, 2:23 PMconst result = await oryPermissionAPI.checkPermission({
namespace: 'Organization',
object: 'organization1',
relation: 'view',
subjectSetNamespace: 'Member',
subjectSetObject: 'XXX',
subjectSetRelation: '',
});
full-diamond-56778
06/13/2023, 2:24 PMsubject_set.namespace
and subject_set.object
-> https://www.ory.sh/docs/keto/reference/rest-api#tag/permission/operation/checkPermissionfull-midnight-13013
06/13/2023, 2:29 PMpermissionApi.expandPermissions({
namespace: "ContentItem",
object: "Recept1",
relation: "view",
},
)...
This returns:
{
"code": 404,
"status": "Not Found",
"message": "no relation tuple found"
}
Any chance you've seen this before as well?full-diamond-56778
06/13/2023, 2:30 PMexpandPermissions
reads relation
as relationships, not permission levels, so please pass relation
as keys of related
object in namepsacesfull-diamond-56778
06/13/2023, 2:30 PMfull-diamond-56778
06/13/2023, 2:33 PMfull-midnight-13013
06/13/2023, 2:33 PMfull-midnight-13013
06/13/2023, 2:34 PMfull-diamond-56778
06/13/2023, 2:37 PMclass Member implements Namespace {}
class Organization implements Namespace {
related: {
owners: Member[]
members: Member[]
solutions: Solution[]
}
permits = {...}
}
class Solution implements Namespace {
related: {
owners: (Member | SubjectSet<Organization, "owners">)[]
members: Member[]
organizations: Organization[]
}
permits = {...}
}
so if executed the expandPermissions
method with (as I remember, with maxDepth: 3
)
{
namespace: 'Solution',
object: 'solution1',
relation: 'owners',
}
I see the deepest relationships with Organization:organization1:owners
-> then I had to call another HTTP API call to retrieve all owners of organization1
full-midnight-13013
06/13/2023, 2:38 PMfull-diamond-56778
06/13/2023, 2:39 PMfull-midnight-13013
06/13/2023, 2:39 PMfull-diamond-56778
06/13/2023, 2:40 PMSo that means you basically get 1 step per request?you can call it then as:
{
namespace: 'Organization',
relation: 'owners',
}
and you will see all relationships between Members and Organizations, so you can easy filter them based on needed object (in my case, the organization)full-diamond-56778
06/13/2023, 2:40 PMfull-midnight-13013
06/13/2023, 2:41 PMfull-diamond-56778
06/13/2023, 2:41 PMmaxDepth
can fix that issue, I will try to do this tomorrowfull-diamond-56778
06/13/2023, 2:42 PMfull-midnight-13013
06/13/2023, 2:43 PMfull-midnight-13013
06/13/2023, 2:43 PMfull-diamond-56778
06/13/2023, 2:44 PMmaxDepth: 3
full-midnight-13013
06/13/2023, 2:44 PMfull-diamond-56778
06/13/2023, 2:45 PM