@@ -15,14 +15,16 @@ Those familiar with configuring IAM on the major cloud providers should feel com
1515- Roles
1616- Policies
1717
18- ## Service Accounts
18+ ## Components
19+
20+ ### Service Accounts
1921
2022Service Accounts represent your unique workloads.
2123We recommend creating a Service Account for each application that will access the SpiceDB API.
2224
2325By default Service Accounts have no access to the SpiceDB API; you must apply a Role to gain access.
2426
25- ## Tokens
27+ ### Tokens
2628
2729Tokens are long-lived credentials for Service Accounts.
2830SpiceDB clients must provide a Token in the Authorization header of an API request to perform actions granted to the Service Account.
@@ -31,7 +33,7 @@ Service Accounts can have an arbitrary number of Tokens.
3133
3234<Callout type = " info" >We recommend deploying new Tokens before deprovisioning any old Tokens to avoid downtime.</Callout >
3335
34- ### Token Format
36+ #### Token Format
3537
3638<Callout type = " warning" >The entire contents of a Token is considered secret.</Callout >
3739
@@ -62,7 +64,7 @@ The command should output the hash, which can be referenced in your static confi
6264
6365[ static configuration ] : #static-configuration
6466
65- ## Roles
67+ ### Roles
6668
6769Roles define rules for accessing the SpiceDB API.
6870Roles are bound to Service Accounts to apply those rules to all API Tokens representing the Service Account.
@@ -89,9 +91,51 @@ The following variables are provided the CEL expression varying based on the req
8991[ cel ] : https://github.com/google/cel-spec
9092[ cel-lang-spec ] : https://github.com/google/cel-spec/blob/81e07d7cf76e7fc89b177bd0fdee8ba6d6604bf5/doc/langdef.md
9193
92- ### Example Rule Expressions
94+ ### Policies
95+
96+ Policies are what bind Roles to a Service Account.
97+
98+ Each policy is composed of a unique identifer for the policy itself, the principal (the target of the role assignment), and any roles being assigned.
99+
100+ ## Task-Specific Configuration
101+
102+ ### ` zed backup ` /` zed restore `
103+
104+ To configure a service account for use with ` zed backup ` and ` zed restore ` , you'll need the following APIs:
105+
106+ On a Service Account on the ** source** PS:
107+
108+ ``` yaml
109+ # # For backup
110+ # Exporting relationships
111+ authzed.api/ExportBulkRelationships
112+ authzed.api/BulkExportRelationships
113+
114+ # Dumping existing schema
115+ authzed.api/ReadSchema
116+ ```
117+
118+ On a Service Account on the ** destination** PS:
119+
120+ ``` yaml
121+ # # For restore
122+ # # Put these on the DESTINATION PS
123+ # Importing relationships
124+ authzed.api/ImportBulkRelationships
125+ authzed.api/BulkImportRelationships
126+
127+ # Retrying failed relationships
128+ authzed.api/WriteRelationships
129+
130+ # Writing new schema
131+ authzed.api/WriteSchema
132+ ```
133+
134+ ## Example Rule CEL Expressions
93135
94- #### Resource-type Write Limit
136+ These are some examples of CEL expressions that you might attach to Permissions on a Role.
137+
138+ ### Resource-type Write Limit
95139
96140This CEL expression disables the ability for writes to occur on anything but the provided resource type.
97141
@@ -101,15 +145,15 @@ This is useful for limiting an application to only be able to perform writes to
101145WriteRelationshipsRequest.updates.all(x, x.relationship.resource.object_type == "resource")
102146```
103147
104- #### Subject-type Write Limit
148+ ### Subject-type Write Limit
105149
106150This CEL expression disables the ability for writes to occur on anything but the provided subject type.
107151
108152``` cel
109153WriteRelationshipsRequest.updates.all(x, x.relationship.subject.object.object_type == "user")
110154```
111155
112- #### Create-only Write Limit
156+ ### Create-only Write Limit
113157
114158This CEL expression disables the ability for writes to perform updates; they can only create new relationships.
115159
@@ -120,15 +164,15 @@ WriteRelationshipsRequest.updates.all(
120164)
121165```
122166
123- #### Resource-type Read Limit
167+ ### Resource-type Read Limit
124168
125169This CEL expression limits the ReadRelationships API from being able to list anything but the a specific resource type.
126170
127171``` cel
128172ReadRelationshipsRequest.relationship_filter.resource_type == "resource"
129173```
130174
131- #### Blocking Schema Writes
175+ ### Blocking Schema Writes
132176
133177This CEL expression prevents any schema writes that contain the substring "blockchain".
134178This example could be extended to prevent PII or undesirable patterns from reaching a production schema.
@@ -137,20 +181,14 @@ This example could be extended to prevent PII or undesirable patterns from reach
137181!WriteSchemaRequest.schema.contains("blockchain")
138182```
139183
140- #### Limit Checks to one Permission
184+ ### Limit Checks to one Permission
141185
142186This CEL expression limits CheckPermissions requests to only be able to check a particular permission.
143187
144188``` cel
145189CheckPermissionRequest.permission == "admin"
146190```
147191
148- ## Policies
149-
150- Policies are what bind Roles to a Service Account.
151-
152- Each policy is composed of a unique identifer for the policy itself, the principal (the target of the role assignment), and any roles being assigned.
153-
154192## Static Configuration
155193
156194Enterprise builds of SpiceDB can have their API access configured statically with a YAML configuration file.
0 commit comments