<@U04UQ68083H> { "namespace": "Document", "obj...
# ory-copilot
l
@chilly-king-10285 { "namespace": "Document", "object": "test.txt", "relation": "owners", "subject_set": { "namespace": "Roles", "object": "Front-desk", "relation": "child", "subject_set" : { "namespace": "SubRoles", "relation" : "Users" } } } this is the request body for creating the relationship. Is it correct?
c
A message from kapa.ai
Based on the information provided in the extracts, the request body for creating a relationship should look like this:
Copy code
json {   "namespace": "string",   "object": "string",   "relation": "string",   "subject_id": "string",   "subject_set": {     "namespace": "string",     "object": "string",     "relation": "string"   } }
In your request body, you have an additional
subject_set
nested inside the first
subject_set
, which is not mentioned in the provided extracts. Also, the
subject_id
field is missing in your request body. According to the extracts, either
subject_set
or
subject_id
can be provided. So, your request body should look something like this:
Copy code
json {   "namespace": "Document",   "object": "test.txt",   "relation": "owners",   "subject_id": "string",   "subject_set": {     "namespace": "Roles",     "object": "Front-desk",     "relation": "child"   } }
Please replace
"string"
with the actual value you want to use. Source: [Ory API Reference](https://www.ory.sh/docs/reference/api)
l
@chilly-king-10285 please explain this request body
c
A message from kapa.ai
A message from kapa.ai
Sure, I'd be happy to explain. In Ory, a relationship is a way to define the connection between an object (the resource you want to manage) and a subject (the entity that wants to access the resource). This relationship is defined within a namespace, which is a context where the relationship is defined and configured. The request body you provided is used to create a relationship in Ory. Here's a breakdown of each field: - `namespace`: This is the context in which the relationship is defined. In your example, the namespace is "Document", which could represent a type of resource you want to manage. - `object`: This is the specific instance of the resource you want to manage within the namespace. In your example, the object is "test.txt", which could represent a specific document. - `relation`: This defines the type of relationship between the object and the subject. In your example, the relation is "owners", which could mean that the subjects are owners of the document "test.txt". - `subject_id`: This is the specific instance of the subject that has the defined relationship with the object. This field is missing in your example. - `subject_set`: This is similar to
subject_id
but allows you to define a set of subjects that have the defined relationship with the object. In your example, the subject set is defined within the "Roles" namespace with the object "Front-desk" and the relation "child". This could mean that all subjects that are children of the "Front-desk" role are owners of the document "test.txt". Please note that according to the provided extracts, either
subject_set
or
subject_id
can be provided, not both. Source: [Ory API Reference](https://www.ory.sh/docs/reference/api)
Sure, I'd be happy to explain the request body.
Copy code
json {   "namespace": "Document",   "object": "test.txt",   "relation": "owners",   "subject_id": "string",   "subject_set": {     "namespace": "Roles",     "object": "Front-desk",     "relation": "child"   } }
Here's what each field represents: - `namespace`: This is the namespace to query. In this case, it's "Document". - `object`: This is the object to query. In this case, it's "test.txt". - `relation`: This is the relation to query. In this case, it's "owners". - `subject_id`: This is the SubjectID to query. Either SubjectSet or SubjectID can be provided. In this case, it's a placeholder string. - `subject_set`: This is an object that represents the Subject Set. It has the following properties: - `namespace`: This is the namespace of the Subject Set. In this case, it's "Roles". - `object`: This is the object of the Subject Set. In this case, it's "Front-desk". - `relation`: This is the relation of the Subject Set. In this case, it's "child". This request body is used to create a relationship in the Ory system. The relationship is defined by the
namespace
,
object
, and
relation
fields, and it involves the subject defined by either the
subject_id
or the
subject_set
. Source: [Ory API Reference](https://www.ory.sh/docs/reference/api)
l
@chilly-king-10285 What is the need of relation of subject_set
c
A message from kapa.ai
The
relation
field within the
subject_set
is used to specify the type of relationship that the subjects in the set have with the object. In the context of Ory, a
subject_set
is a set of all subjects that have a specific relation on an object. They empower Ory Permissions to be as flexible as needed by defining indirections. They can be used to realize, for example, Role-Based Access Control (RBAC) or inheritance of relations. Subject sets themselves can again indirect to subject sets. So, the
relation
in
subject_set
is crucial to define the specific type of connection or access that the group of subjects (defined in the
subject_set
) has with the object. For example, in the request body you provided:
Copy code
json {{   "namespace": "Document",   "object": "test.txt",   "relation": "owners",   "subject_set": {{     "namespace": "Roles",     "object": "Front-desk",     "relation": "child"   }} }}
The
relation
"child" within the
subject_set
could mean that all subjects that are children of the "Front-desk" role in the "Roles" namespace are owners of the document "test.txt" in the "Document" namespace. Sources: - [Ory API Reference](https://www.ory.sh/docs/reference/api) - [Ory Keto Concepts - Subjects](https://www.ory.sh/docs/keto/concepts/subjects)