2
2
3
3
This guide explains how to configure permission requests for a Google Zanzibar-based [ Authzed/SpiceDB] ( https://authzed.com ) instance using gRPC.
4
4
5
- ## Requisites
5
+ ## Prerequisites
6
6
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.
8
8
9
- ## Run the guide ① → ⑥
9
+ ## Run the guide ① → ⑦
10
10
11
- ### ① Setup
11
+ ### ① Deploy Toy Store application
12
12
13
- Clone the repo:
13
+ Deploy a simple HTTP application service that echoes back the request data:
14
14
15
15
``` 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
17
17
```
18
18
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:
20
21
21
22
``` 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
-
42
23
kubectl apply -f - << EOF
43
24
apiVersion: gateway.networking.k8s.io/v1
44
25
kind: HTTPRoute
@@ -66,22 +47,23 @@ spec:
66
47
EOF
67
48
```
68
49
69
- Export the gateway hostname and port:
50
+ Export the gateway hostname and port for testing :
70
51
71
52
``` sh
72
53
export INGRESS_HOST=$( kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath=' {.status.addresses[0].value}' )
73
54
export INGRESS_PORT=$( kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath=' {.spec.listeners[?(@.name=="http")].port}' )
74
55
export GATEWAY_URL=$INGRESS_HOST :$INGRESS_PORT
75
56
```
76
57
58
+ ### ③ Test the Unprotected Application
77
59
Test requests to the unprotected application:
78
60
79
61
``` sh
80
62
curl -H ' Host: api.toystore.com' http://$GATEWAY_URL /posts -i
81
63
# HTTP/1.1 200 OK
82
64
```
83
65
84
- ### ③ Create the permission database
66
+ ### ④ Create the permission database
85
67
86
68
Create the namespace for SpiceDB:
87
69
@@ -206,7 +188,7 @@ curl -X POST http://localhost:8443/v1/relationships/write \
206
188
EOF
207
189
```
208
190
209
- ### ④ Create an ` AuthPolicy `
191
+ ### ⑤ Create an ` AuthPolicy `
210
192
211
193
Store the shared token for Authorino authentication with the SpiceDB instance (must be created in the same namespace as the Kuadrant CR):
212
194
@@ -272,7 +254,7 @@ spec:
272
254
EOF
273
255
```
274
256
275
- ### ⑤ Create the API keys
257
+ ### ⑥ Create the API keys
276
258
277
259
For Emilia (writer):
278
260
@@ -310,9 +292,9 @@ stringData:
310
292
EOF
311
293
```
312
294
313
- ### ⑥ Consume the API
295
+ ### ⑦ Consume the API
314
296
315
- As Emilia, send a GET request:
297
+ As Emilia, send a ` GET ` request:
316
298
317
299
``` sh
318
300
curl -H ' Host: api.toystore.com' -H ' Authorization: APIKEY IAMEMILIA' \
@@ -321,7 +303,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
321
303
# HTTP/1.1 200 OK
322
304
```
323
305
324
- As Emilia, send a POST request:
306
+ As Emilia, send a ` POST ` request:
325
307
326
308
``` sh
327
309
curl -H ' Host: api.toystore.com' -H ' Authorization: APIKEY IAMEMILIA' \
@@ -330,7 +312,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMEMILIA' \
330
312
# HTTP/1.1 200 OK
331
313
```
332
314
333
- As Beatrice, send a GET request:
315
+ As Beatrice, send a ` GET ` request:
334
316
335
317
``` sh
336
318
curl -H ' Host: api.toystore.com' -H ' Authorization: APIKEY IAMBEATRICE' \
@@ -339,7 +321,7 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
339
321
# HTTP/1.1 200 OK
340
322
```
341
323
342
- As Beatrice, send a POST request:
324
+ As Beatrice, send a ` POST ` request:
343
325
344
326
``` sh
345
327
curl -H ' Host: api.toystore.com' -H ' Authorization: APIKEY IAMBEATRICE' \
@@ -351,16 +333,8 @@ curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY IAMBEATRICE' \
351
333
352
334
## Cleanup
353
335
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
-
362
336
``` 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
364
338
kubectl delete httproute toystore
365
339
kubectl delete authpolicy route-auth
366
340
kubectl delete kuadrant kuadrant -n kuadrant-system
0 commit comments