Skip to content

Commit e47c6a3

Browse files
committed
refactor: layout and setup
Signed-off-by: KevFan <[email protected]>
1 parent 0552117 commit e47c6a3

File tree

1 file changed

+19
-45
lines changed

1 file changed

+19
-45
lines changed

doc/user-guides/authzed.md doc/user-guides/auth/authzed.md

+19-45
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,24 @@
22

33
This guide explains how to configure permission requests for a Google Zanzibar-based [Authzed/SpiceDB](https://authzed.com) instance using gRPC.
44

5-
## Requisites
5+
## Prerequisites
66

7-
- [Docker](https://docker.io)
7+
You have installed Kuadrant in a [kubernetes](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-kubernetes/) or [OpenShift](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-openshift/) cluster.
88

9-
## Run the guide ① →
9+
## Run the guide ① →
1010

11-
### Setup
11+
### Deploy Toy Store application
1212

13-
Clone the repo:
13+
Deploy a simple HTTP application service that echoes back the request data:
1414

1515
```sh
16-
git clone git@github.com:Kuadrant/kuadrant-operator.git && cd kuadrant-operator
16+
kubectl apply -f https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/refs/heads/main/examples/toystore/toystore.yaml
1717
```
1818

19-
Run the following command to create a local Kubernetes cluster with [Kind](https://kind.sigs.k8s.io/), install & deploy Kuadrant:
19+
### ② Expose the Application
20+
Create an `HTTPRoute` to expose a `/posts` path for `GET` and `POST` requests to the application:
2021

2122
```sh
22-
make local-setup
23-
```
24-
25-
Request an instance of Kuadrant in the `kuadrant-system` namespace:
26-
27-
```sh
28-
kubectl -n kuadrant-system apply -f - <<EOF
29-
apiVersion: kuadrant.io/v1beta1
30-
kind: Kuadrant
31-
metadata:
32-
name: kuadrant
33-
spec: {}
34-
EOF
35-
```
36-
37-
### ② Deploy the Talker API
38-
39-
```sh
40-
kubectl apply -f examples/toystore/toystore.yaml
41-
4223
kubectl apply -f - <<EOF
4324
apiVersion: gateway.networking.k8s.io/v1
4425
kind: HTTPRoute
@@ -66,22 +47,23 @@ spec:
6647
EOF
6748
```
6849

69-
Export the gateway hostname and port:
50+
Export the gateway hostname and port for testing:
7051

7152
```sh
7253
export INGRESS_HOST=$(kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath='{.status.addresses[0].value}')
7354
export INGRESS_PORT=$(kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
7455
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
7556
```
7657

58+
### ③ Test the Unprotected Application
7759
Test requests to the unprotected application:
7860

7961
```sh
8062
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/posts -i
8163
# HTTP/1.1 200 OK
8264
```
8365

84-
### Create the permission database
66+
### Create the permission database
8567

8668
Create the namespace for SpiceDB:
8769

@@ -206,7 +188,7 @@ curl -X POST http://localhost:8443/v1/relationships/write \
206188
EOF
207189
```
208190

209-
### Create an `AuthPolicy`
191+
### Create an `AuthPolicy`
210192

211193
Store the shared token for Authorino authentication with the SpiceDB instance (must be created in the same namespace as the Kuadrant CR):
212194

@@ -272,7 +254,7 @@ spec:
272254
EOF
273255
```
274256

275-
### Create the API keys
257+
### Create the API keys
276258

277259
For Emilia (writer):
278260

@@ -310,9 +292,9 @@ stringData:
310292
EOF
311293
```
312294

313-
### Consume the API
295+
### Consume the API
314296

315-
As Emilia, send a GET request:
297+
As Emilia, send a `GET` request:
316298

317299
```sh
318300
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
@@ -321,7 +303,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
321303
# HTTP/1.1 200 OK
322304
```
323305

324-
As Emilia, send a POST request:
306+
As Emilia, send a `POST` request:
325307

326308
```sh
327309
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
@@ -330,7 +312,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
330312
# HTTP/1.1 200 OK
331313
```
332314

333-
As Beatrice, send a GET request:
315+
As Beatrice, send a `GET` request:
334316

335317
```sh
336318
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
@@ -339,7 +321,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
339321
# HTTP/1.1 200 OK
340322
```
341323

342-
As Beatrice, send a POST request:
324+
As Beatrice, send a `POST` request:
343325

344326
```sh
345327
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
@@ -351,16 +333,8 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
351333

352334
## Cleanup
353335

354-
If you have started a Kubernetes cluster locally with Kind to try this user guide, delete it by running:
355-
356-
```sh
357-
make local-cleanup
358-
```
359-
360-
Otherwise, delete the resources created in each step:
361-
362336
```sh
363-
kubectl delete -f examples/toystore/toystore.yaml
337+
kubectl delete -f https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/refs/heads/main/examples/toystore/toystore.yaml
364338
kubectl delete httproute toystore
365339
kubectl delete authpolicy route-auth
366340
kubectl delete kuadrant kuadrant -n kuadrant-system

0 commit comments

Comments
 (0)