Skip to content

Commit bc2daef

Browse files
committed
Make some edits
1 parent 7f304e3 commit bc2daef

File tree

3 files changed

+122
-29
lines changed

3 files changed

+122
-29
lines changed

app/authzed/guides/setting-up-private-networking/page.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,30 @@ Most users of AuthZed Dedicated on GCP privately connect to SpiceDB with GCP [Pr
114114
1. Navigate to “Private Service Connect” and make sure you are on the “Connected Endpoints” tab.
115115
1. Click “Connect Endpoint”
116116

117-
| Option | Selection |
118-
|------------------------|------------------------------------------------|
119-
| Target | “Published service” |
120-
| Target service | This will be provided to you by Authzed |
121-
| Endpoint name | Name this whatever you want |
122-
| Network and subnetwork | Select the networks you need connectivity from |
123-
| IP address | Choose whatever IP you'd like |
117+
| Option | Selection |
118+
| ---------------------- | ---------------------------------------------- |
119+
| Target | “Published service” |
120+
| Target service | This will be provided to you by Authzed |
121+
| Endpoint name | Name this whatever you want |
122+
| Network and subnetwork | Select the networks you need connectivity from |
123+
| IP address | Choose whatever IP you'd like |
124124

125125
### Enable DNS
126126

127127
1. Navigate to Cloud DNS and create a zone
128128

129-
| Option | Selection |
130-
|-----------|---------------------------------------------------------------------------|
131-
| Zone type | private |
132-
| DNS Name | This will be provided to you by Authzed |
133-
| Networks | Select the network where the Private Service Connect endpoint is deployed |
129+
| Option | Selection |
130+
| --------- | ------------------------------------------------------------------------- |
131+
| Zone type | private |
132+
| DNS Name | This will be provided to you by Authzed |
133+
| Networks | Select the network where the Private Service Connect endpoint is deployed |
134134

135135
1. Add record set
136136

137-
| Option | Selection |
138-
|------------|------------------------------------------------|
139-
| DNS name | This will be provided to you by Authzed |
140-
| IP address | Enter your Private Service Connect endpoint IP |
137+
| Option | Selection |
138+
| ---------- | ---------------------------------------------- |
139+
| DNS name | This will be provided to you by Authzed |
140+
| IP address | Enter your Private Service Connect endpoint IP |
141141

142142
### Add Permission System
143143

@@ -150,15 +150,15 @@ Most users of AuthZed Dedicated on GCP privately connect to SpiceDB with GCP [Pr
150150

151151
Verify connectivity from client machine with the [Zed CLI tool](https://github.com/authzed/zed)
152152

153-
``` zed
153+
```zed
154154
zed context set permission_system_name example.com:443 sdbst_h256_123
155155
```
156156

157-
``` zed
157+
```zed
158158
zed schema write example.yaml
159159
```
160160

161-
``` zed
161+
```zed
162162
zed schema read
163163
```
164164

app/spicedb/concepts/querying-data/page.mdx

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Callout } from "nextra/components";
22

33
# Querying Data
44

5-
This page walks through the main ways to query data in SpiceDB. The options are listed from most preferred to least preferred in terms of performance, but the right choice always depends on your use case.
5+
This page walks through the main ways to query data in SpiceDB. The options are listed roughly in the order of how often you should be calling them, and roughly in order of their expected performance. Choose the one that makes sense for your use case, but consider whether your use case actually requires the call you're looking at.
66

77
<Callout type="info">
88
In most of the APIs below, if you want to be able to read your write, you can
@@ -19,6 +19,18 @@ This page walks through the main ways to query data in SpiceDB. The options are
1919

2020
## Check Permission
2121

22+
Send:
23+
24+
- Subject Type
25+
- Subject ID
26+
- Permission (or relation)
27+
- Object Type
28+
- Object ID
29+
30+
Receive:
31+
32+
- Yes/no (or a provisional response if missing caveat data)
33+
2234
[`CheckPermission`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.CheckPermission) is the go-to for most access checks. It’s designed for high-traffic workloads.
2335

2436
You can debug a check locally with `zed permission check resource:someresource somepermission user:someuser --explain` to understand how the decision was made.
@@ -29,21 +41,69 @@ The `subject` of the query can be a single user (e.g. `user:someuser`) or a set
2941

3042
### CheckBulkPermissions
3143

44+
Send Many:
45+
46+
- Subject Type
47+
- Subject ID
48+
- Permission (or relation)
49+
- Object Type
50+
- Object ID
51+
52+
Receive Many:
53+
54+
- Yes/no (or a provisional response if missing caveat data)
55+
3256
If your app needs to do multiple checks (for example, for various subjects), use the [`CheckBulkPermissions`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.CheckBulkPermissions) API. It's great for UI workloads where you need to check multiple permissions at once: think tables, lists, and dashboards.
3357

58+
It's also the recommended way to ask "what permissions does a given subject have on a resource?"
59+
Make a check for each permission in your schema. This will require you to update calling code when you add permissions,
60+
but the consuming code will need to be changed to include the logic associated with the new permission in any case.
61+
3462
It's always preferable to perform one call to `CheckBulkPermissions` with N checks than N calls to `CheckPermission`, unless you don't want to wait for the N checks to finish.
3563

3664
## LookupResources
3765

38-
[`LookupResources`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.LookupResources) is a good choice when you need to find all resources of a given type that a specific subject can access. It supports cursoring and works well for moderate result sizes.
66+
Send Many:
67+
68+
- Subject Type
69+
- Subject ID
70+
- Permission (or relation)
71+
- Object Type
72+
73+
Receive many:
3974

40-
If you’re expecting more than ~10,000 results, this isn't ideal. See [this](../modeling/protecting-a-list-endpoint#checking-with-checkbulkpermissions) for more details.
75+
- Object ID
4176

42-
[Materialize]: /authzed/concepts/authzed-materialize
77+
[`LookupResources`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.LookupResources) is a good choice when you need to find all resources of a given type that a specific subject can access. It supports cursoring and works well for moderate result sizes.
78+
79+
It's a good way to do [prefiltering of results](/spicedb/modeling/protecting-a-list-endpoint#filtering-with-lookupresources) in
80+
a List endpoint, but it's a heavy request that can cause performance problems when more than 10k results are involved.
81+
In that case we recommend postfiltering with [CheckBulk](#checkbulkpermissions), and if that still doesn't work,
82+
we recommend evaluating [Materialize](/authzed/concepts/authzed-materialize).
4383

4484
## LookupSubjects
4585

46-
[`LookupSubjects`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.LookupSubjects) returns all subjects that have access to a specific resource. It does not support cursoring, and the response includes a list of objects that have been explicitly excluded.
86+
Send Many:
87+
88+
- Subject Type
89+
- Permission (or relation)
90+
- Object Type
91+
- Object ID
92+
93+
Receive many:
94+
95+
- Subject ID
96+
97+
[`LookupSubjects`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.LookupSubjects) returns
98+
all subjects that have access to a specific resource. It does not support cursoring.
99+
100+
It's commonly used to drive UIs and APIs that list users with given permission or set of permissions, such as a table of Admins
101+
on a particular Organization.
102+
103+
Note that LookupSubjects will do a full path walk between an object and a subject, and will consider all valid paths between object and subject.
104+
If you are looking to find all the subjects that are on a specific relation, use `ReadRelationships` instead of `LookupSubjects`.
105+
106+
If your schema includes exclusions and wildcards, the response can include a list of subjects that have been explicitly excluded.
47107

48108
For example, if the schema is
49109

@@ -67,16 +127,41 @@ document:finance#blocked@user:bob
67127

68128
Then `LookupSubjects` for `document:finance` will return a response of the form `{user:* - [user:anne,user:bob]}`.
69129

70-
If you are looking to find all the subjects that are on a specific relation, use `ReadRelationships` instead of `LookupSubjects`.
71-
72130
## ReadRelationships
73131

74-
[`ReadRelationships`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.ReadRelationships) should be your last resort. It's slower, it doesn't populate or use the permissions cache, and it won't evaluate caveats. Use it only when you truly need raw relationship data and none of the higher-level APIs fit the job.
132+
[`ReadRelationships`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.ReadRelationships) is intended a an escape hatch,
133+
and should only be considered if no other API matches your use case.
134+
135+
It's considerably more flexible in that you can send any combination of:
136+
137+
- Subject Type
138+
- Subject ID
139+
- Permission (or relation)
140+
- Object Type
141+
- Object ID
142+
143+
And receive all relationships that match that filter, but it comes with some important caveats:
144+
145+
- It's generally less optimized than the `Check` and `Lookup` APIs because of that flexibility
146+
- It does no caching. The `Check` and `Lookup` APIs gain much of their performance by caching the results of subproblem computation; `ReadRelationships` does no caching and will go directly to the database every time.
147+
- The indexes in the backing [datastores](/spicedb/concepts/datastores) are optimized around the `Check` and `Lookup` APIs, so it's possible to
148+
craft a `ReadRelationships` request that misses indexes and requires a full table scan. This is because covering all combinations of filters
149+
with an index would impact write performance too much.
150+
151+
Some use cases where `ReadRelationships` may be warranted:
152+
153+
- Deleting all relationships in a subtree, where a simple [RelationshipFilter](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.RelationshipFilter) in a [DeleteRelationships](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.DeleteRelationshipsRequest) would be insufficient
154+
- Admin UIs that show lists of roles or relationships between objects
75155

76156
## Watch
77157

78-
The Watch API is not meant to answer permission questions but to serve other use-cases, like auditing. See [this](watch) for more details.
158+
The Watch API is not meant to answer permission questions but to serve other use-cases, like auditing. See [the Watch API documentation](/spicedb/concepts/watch) for more details.
79159

80160
## ExpandPermissionTree
81161

82-
This [ExpandPermissionTree](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.ExpandPermissionTree) API is useful in scenarios where your UI needs to show which users _and groups_ have access to something.
162+
This [ExpandPermissionTree](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.ExpandPermissionTree) API
163+
comes from the [Zanzibar Paper](https://authzed.com/zanzibar#2.4.5-expand). It allows you to examine the subtree of relationships
164+
around a particular point in the graph, and is useful in scenarios like your UI needing to show which users _and groups_ have access to something.
165+
166+
In practice we don't see many uses of this API, especially because it only resolves one "hop" in the graph at a time and must be called
167+
repeatedly to get a full picture of a subtree.

app/spicedb/getting-started/faq/page.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ Choose based on your scale: start with LookupResources, move to CheckBulkPermiss
6060

6161
[Learn more]: ../modeling/protecting-a-list-endpoint
6262

63+
## How do I get all of the permissions a subject has on a resource?
64+
65+
There isn't an API that answers this question directly. Instead, you should use the
66+
[`CheckBulkPermissions`](https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.CheckBulkPermissions) API and send a check for each of the permissions you want to check.
67+
68+
It means that you'll need to update your permission checks when you add a new permission, but you'd need to update the calling code
69+
to handle the concept that a new permission represents anyway.
70+
6371
## How can I get involved with SpiceDB?
6472

6573
The best first step is to join [Discord].

0 commit comments

Comments
 (0)