You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,19 +6,15 @@ description: Built-in Functions that can be used in your policy
6
6
7
7
# Built-in Functions
8
8
9
-
Topaz provides a set of built-in functions that can be used in your policy. These functions make it easier to leverage information found the Topaz directory.
9
+
Topaz provides a set of built-in functions that can be used in your policy. These functions make it easier to leverage information from the Topaz directory.
10
10
11
-
### `ds.identity`
12
-
```js
13
-
ds.identity({
14
-
"id":"<value>"
15
-
})
16
-
```
17
-
Looks up a user identity by one of the ids (e.g. email address or PID), and returns the `identifier` of the user object associated to the identity instance.
18
11
19
-
For example: `ds.identity({ "id": "[email protected]" })` will return `dfdadc39-7335-404d-af66-c77cf13a15f8`.
20
12
21
13
### `ds.object`
14
+
15
+
> `ds.object` is an OPA built-in function, wrapping the gRPC directory reader [GetObject](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.GetObject) function,
16
+
taking in a [GetObjectRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetObjectRequest) as input, returning a [GetObjectResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetObjectResponse).
17
+
22
18
```js
23
19
ds.object({
24
20
"object_type":"<object type>",
@@ -35,6 +31,8 @@ If `with_relation` is included and set to `true`, the response includes all the
35
31
36
32
### `ds.relation`
37
33
34
+
> `ds.relation` is an OPA built-in function, wrapping the gRPC directory reader [GetRelation](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.GetRelation) function, taking in a [GetRelationRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetRelationRequest) as input, returning a [GetRelationResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetRelationResponse).
35
+
38
36
```js
39
37
ds.relation({
40
38
"object_type":"<object type>",
@@ -49,59 +47,53 @@ ds.relation({
49
47
Returns the relation instance that connects the subject with the object through the relation identified by `<object type>` and `<relation name>`.
50
48
If `with_objects` is included and set to `true`, the response includes all the subject and object instances.
51
49
52
-
### `ds.check`
50
+
### `ds.relations`
51
+
52
+
> `ds.relations` is an OPA built-in function, wrapping the gRPC directory reader [GetRelations](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.GetRelations) function, taking in a [GetRelationsRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetRelationsRequest) as input, returning a [GetRelationsResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetRelationsResponse).
53
53
54
54
```js
55
-
ds.check({
55
+
ds.relations({
56
56
"object_type":"<object type>",
57
57
"object_id":"<object identifier>",
58
-
"relation":"<relation or permission name>",
58
+
"relation":"<relation name>",
59
59
"subject_type":"<subject type>",
60
-
"subject_id":"<subject identifier>"
60
+
"subject_id":"<subject identifier>",
61
+
"subject_relation":"subject relation name>",
62
+
"with_objects":<boolean>,
63
+
"with_empty_subject_relation":<boolean>
61
64
})
62
65
```
63
66
64
-
An object is identified by the combination of its `<object type>` and `<object identifier>`. The same is true for a subject.
65
-
66
-
A relation type is uniquely identified by the object type name and the relation name. A relation instance of that type will relate an object instance to a subject instance.
67
-
68
-
`ds.check` returns `true` if the object instance has a relation or permission of the type specified to the subject instance.
69
-
67
+
### `ds.check`
70
68
71
-
###`ds.check_relation`
69
+
>`ds.check` is an OPA built-in function, wrapping the gRPC directory reader [Check](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.Check) function, taking in a [CheckRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.CheckRequest) as input, returning a [CheckResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.CheckResponse).
72
70
73
71
```js
74
-
ds.check_relation({
72
+
ds.check({
75
73
"object_type":"<object type>",
76
74
"object_id":"<object identifier>",
77
-
"relation":"<relation name>",
75
+
"relation":"<relation or permission name>",
78
76
"subject_type":"<subject type>",
79
77
"subject_id":"<subject identifier>"
80
78
})
81
79
```
80
+
82
81
An object is identified by the combination of its `<object type>` and `<object identifier>`. The same is true for a subject.
83
82
84
83
A relation type is uniquely identified by the object type name and the relation name. A relation instance of that type will relate an object instance to a subject instance.
85
84
86
-
`ds.check_relation` returns `true` if the object instance has a relation of the type specified to the subject instance.
85
+
`ds.check` returns `true` if the object instance has a relation or permission of the type specified to the subject instance.
87
86
88
-
### `ds.check_permission`
89
87
90
-
```js
91
-
ds.check_permission({
92
-
"object_type":"<object type>",
93
-
"object_id":"<object identifier>",
94
-
"permission":"<permission name>",
95
-
"subject_type":"<subject type>",
96
-
"subject_id":"<subject identifier>"
97
-
})
98
-
```
99
-
An object is identified by the combination of its `<object type>` and `<object identifier>`. The same is true for a subject.
88
+
### `ds.checks`
89
+
90
+
> `ds.checks` is an OPA built-in function, wrapping the gRPC directory reader [Checks](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.Checks) function, taking in a [ChecksRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.ChecksRequest) as input, returning a [ChecksResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.ChecksResponse).
100
91
101
-
`ds.check_permission` returns`true` if the subject has the permission `<permission name>` referenced through one or more relations to the object.
102
92
103
93
### `ds.graph`
104
94
95
+
> `ds.graph` is an OPA built-in function, wrapping the gRPC directory reader [GetGraph](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.Reader.GetGraph) function, taking in a [GetGraphRequest](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetGraphRequest) as input, returning a [GetGraphResponse](https://buf.build/aserto-dev/directory/docs/v0.33.5:aserto.directory.reader.v3#aserto.directory.reader.v3.GetGraphResponse).
96
+
105
97
```js
106
98
ds.graph({
107
99
"object_type":"<object type>",
@@ -122,3 +114,230 @@ If `object_id` is provided, the results include all subjects of the specified `s
122
114
If `subject_id` is provided, the results include all objects of the specified type with which the subject has the given relation.
123
115
124
116
If `explain` is set to `true` the output also includes all the graph paths that connect the given object or subject with the returned results.
117
+
118
+
119
+
### `ds.identity` (OBSOLETE)
120
+
121
+
```js
122
+
ds.identity({
123
+
"id":"<value>"
124
+
})
125
+
```
126
+
127
+
`ds.identity` can be used to look up `object_id` of the `user``object_type` associated to the `user` object via the 'identifier' relationship between the 'identity' and `user` object instance.
128
+
129
+
The canonical usage pattern using the Citadel data set:
130
+
131
+
```js
132
+
i =ds.identity({"id":"CiRmZDA2MTRkMy1jMzlhLTQ3ODEtYjdiZC04Yjk2ZjVhNTEwMGQSBWxvY2Fs"})
> 'ds.identity' is obsoleted as it has hardcoded dependencies on the existence of the `identity` and `user` object types as well as the `identifier` relationship to associate them. This implementation is a leftover from the early days before the directory exposed a manifest.
142
+
143
+
### `ds.user` (OBSOLETE)
144
+
145
+
```js
146
+
ds.user({
147
+
"id":"<value>"
148
+
})
149
+
```
150
+
151
+
`ds.user` can be used to retrieve the `user` object type instance, associated with a given `identity` value.
152
+
153
+
> `ds.identity` is obsoleted as it has hardcoded dependencies on the existence of the 'user' object type. This implementation is a leftover from the early days before the directory exposed a manifest.
154
+
155
+
The canonical usage pattern using the Citadel data set:
0 commit comments