2
2
3
3
This snippet shows how JWT claims can be used for field arguments.
4
4
5
- This examples demonstrates an number of StepZen capabilities:
5
+ This examples demonstrates a number of StepZen capabilities:
6
6
7
7
- Authorization using JWT
8
8
- Field access rules
9
9
- Field visibility rules
10
10
- ` @value ` directive with access to JWT claims
11
+ - https://www.ibm.com/docs/en/api-connect/ace/saas?topic=directives-directive-value
11
12
- Reshaping
12
13
13
14
## Restricting access through JWT claims.
@@ -17,7 +18,7 @@ is used as a customer's identifier. Thus the customer can only view their own in
17
18
the backend database includes all customers.
18
19
19
20
The field ` Query.customer ` provides an identifier lookup to all customers. This field is restricted
20
- from been executed by an authenticated user by field visibility and access rules.
21
+ from being executed by field visibility and access rules.
21
22
22
23
Instead a field ` Query.me ` is exposed with no field arguments that invokes ` Query.customer `
23
24
with the customer identifier pulled from the ` sub ` claim in the request's JWT.
@@ -27,9 +28,12 @@ This script has access to field arguments of its annotated field (in this case n
27
28
Thus it returns the ` sub ` claim which is then automatically mapped as a scalar value to the sole argument of
28
29
the next step in the sequence (` Query.customer(id:) ` ).
29
30
30
- Note these concepts could be combined with field access through RBAC rules (see XXXX)
31
+ An alternate version of ` Query._myid ` exists ` Query._my_id_jsonata ` showing that scripts can be implemented in JSONata.
32
+ The default langauge is ECMAScript.
33
+
34
+ Note these concepts could be combined with field access through ABAC rules (see ` protection/simpleABACSample ` )
31
35
so that ` Query.customer ` could be exposed, but only customer service reps could call it
32
- with an arbitary identifier.
36
+ with any customer identifier.
33
37
34
38
## Try it out!
35
39
@@ -44,6 +48,7 @@ Run the [sample operations](operations.graphql):
44
48
JWT with ` sub: 5 ` .
45
49
46
50
JWT: https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1In0.LE_mbGsS2FbxF41r4wOYKhWdBoYhnIk0-6d6U7ibF-A
51
+
47
52
Secret Key: development-only
48
53
49
54
```
@@ -53,6 +58,7 @@ stepzen request -f operations.graphql --operation-name=Customer --header "Author
53
58
JWT with ` sub: 9 ` .
54
59
55
60
JWT: https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1In0.LE_mbGsS2FbxF41r4wOYKhWdBoYhnIk0-6d6U7ibF-A
61
+
56
62
Secret Key: development-only
57
63
58
64
```
0 commit comments