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
Copy file name to clipboardExpand all lines: pages/spicedb/getting-started/protecting-a-blog.mdx
+83-6Lines changed: 83 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
import { Callout, Tabs } from'nextra/components'
2
+
importYouTubefrom'react-youtube'
2
3
3
4
# Protecting a Blog Application
4
5
@@ -7,11 +8,13 @@ Not all software requires this level of integration, but it is preferable for gr
7
8
8
9
Instead of introducing an unfamiliar example app and altering various locations in its code, this guide is written such that each step is a standalone snippet of code that demonstrates an integration point and finding where those points exist in your codebase is an exercise left to the reader.
9
10
11
+
Scroll to the bottom of this page for a video walkthrough of creating a Permissions System using AuthZed Cloud.
12
+
10
13
## Prerequisites
11
14
12
15
One of:
13
16
14
-
- An [Authzed] Permission System and associated [API Token] with `admin` access
17
+
- An [Authzed Cloud] Permission System
15
18
- A [running instance] of [SpiceDB][SpiceDB] with the configured preshared key for SpiceDB:
The first step to integrating any software is ensuring you have an API client.
34
+
Sign in to [AuthZed Cloud](https://app.authzed.cloud) and click on the **+Create** button to create a Permissions System (PS) and fill in the necessary details:
35
+
36
+
- The type of the PS can be either Production or Development
37
+
- Give it a name
38
+
- Choose a datastore.
39
+
- The update channel can be either be `rapid` or `regular` which determines the behavior of automatic updates when new SpiceDB releases are made available
40
+
- The Deployments tab has the following options:
41
+
- The name of the deployment
42
+
- A dropdown for the region in which the deployment is made.
43
+
Currently `us-east-1` and `eu-central-1` are available
44
+
- The number of vCPUs for your deployment.
45
+
The recommendation is to start with 2 vCPUs and then monitor the Metrics and change it based on your workload
46
+
- The number of replicas to deploy SpiceDB with primarily read workloads.
47
+
The recommendation is 3 but will depend on your latency requirements.
48
+
49
+
Click the Save button to create a Permissions System
50
+
51
+
## Configuring Access
52
+
53
+
Before using the Permissions System, let's configure access to it.
54
+
This functionality enables organizations to apply the principle of least-privilege to services accessing SpiceDB.
55
+
For example, read-only tokens can be created for services that should never need to write to SpiceDB.
56
+
Read more about it [here](https://authzed.com/docs/authzed/concepts/restricted-api-access)
57
+
58
+
Let’s start by creating a **Service Account** which is something that represents your unique workload.
59
+
We recommend creating a Service Account for each application that will access the SpiceDB API.
60
+
Add a name such as `blog-app` and a description before hitting Save.
61
+
62
+
Now let’s create a **token**.
63
+
Tokens are long-lived credentials for Service Accounts.
64
+
SpiceDB clients must provide a Token in the Authorization header of an API request to perform actions granted to the Service Account.
65
+
Click on the `blog-app` service account you just created and then the Tokens item in the menu.
66
+
Create a token by providing a name and description.
67
+
68
+
Let’s now provide a **Role** and attach a **Policy** to that Role.
69
+
A Role defines rules for accessing the SpiceDB API.
70
+
Roles are bound to Service Accounts.
71
+
Click the Roles -> Create Role and provide a name and a description.
72
+
Add the following permissions for this demo:
73
+
74
+
```
75
+
ReadSchema
76
+
WriteSchema
77
+
DeleteRelationships
78
+
ReadRelationships
79
+
WriteRelationships
80
+
CheckPermission
81
+
```
33
82
83
+
Finally, let’s create a Policy.
84
+
Policies are what bind Roles to a Service Account.
85
+
Click on Policies -> Create policy.
86
+
Provide a name and a description and pick the Service Account and Role created in the steps above to bind the two.
87
+
88
+
You’re now ready to use AuthZed Cloud Permissions System!
89
+
90
+
## Client Installation
91
+
92
+
The first step to integrating any software is ensuring you have an API client.
34
93
Each client is installed with its ecosystem's package management tools:
35
94
95
+
You can also interact with with the Permissions System using [zed](https://github.com/authzed/zed) - the command-line client for managing SpiceDB clusters.
You can find the endpoint on the AuthZed Cloud dashboard.
154
+
Click on the Permissions System that's just been created and locate the **Connect** button.
155
+
Copy the zed command and paste it in your terminal.
156
+
It should look like this:
157
+
158
+
```
159
+
zed context set us-east-1 acme-permission-system-xyz.aws.authzed.cloud:443 <token-here>
160
+
```
161
+
162
+
where `us-east-1` is the name of the PS followed by the endpoint.
163
+
Replace the `token-here` with the token that was generated in the earlier step.
164
+
92
165
## Defining and Applying a Schema
93
166
94
167
Regardless of whether or not you have a preexisting schema written, integrating a new application will typically require you add new definitions to the [Schema].
@@ -1014,3 +1087,7 @@ public class App {
1014
1087
1015
1088
</Tabs.Tab>
1016
1089
</Tabs>
1090
+
1091
+
Here's a video walkthrough of creating a Permissions System on AuthZed Cloud:
0 commit comments