gnodet-bot commented on code in PR #29138:
URL: https://github.com/apache/camel/pull/29138#discussion_r4465431557


##########
components/camel-openfga/src/main/docs/openfga-component.adoc:
##########
@@ -521,6 +521,80 @@ resolved from the registry — 
`conditionContext=#myContext`. A map rather than
 every condition parameter in the authorization model (`int`, `bool`, 
`timestamp`, `ipaddress`), and a map lets you
 supply the right Java type instead of a string the server would reject.
 
+YAML, like a properties file, hands every value over as a string, the entries 
of a map included. OpenFGA converts a
+string for an `int`, `uint`, `double`, `duration`, `timestamp` or `ipaddress` 
parameter, so those can be written as
+they are, but it rejects one for a `bool` parameter: give that as 
`#valueAs(boolean):true`. A `list` or `map` parameter
+cannot be written inline at all; declare it as a bean of its own and refer to 
it with `#bean:`:
+
+[tabs]
+====
+Java::
++
+[source,java]
+------------------------------------------------------------
+Map<String, Object> networkContext = Map.of(
+        "trusted", true,
+        "allowed_regions", List.of("eu", "us"));
+context.getRegistry().bind("networkContext", networkContext);
+
+from("direct:checkFromTrustedNetwork")
+    .to("openfga:check?storeId={{fga.store}}&relation=reader"
+        + "&user=user:${exchangeProperty.CamelKeycloakTokenSubject}"
+        + 
"&object=document:${header.documentId}&conditionContext=#networkContext");
+------------------------------------------------------------
+
+YAML::
++
+[source,yaml]
+----
+- beans:
+    - name: allowedRegions
+      type: java.util.ArrayList
+      properties:
+        "0": eu
+        "1": us
+    - name: networkContext
+      type: java.util.LinkedHashMap
+      properties:
+        # a bool parameter needs a boolean: the string "true" is rejected
+        trusted: "#valueAs(boolean):true"
+        # a list parameter needs a list
+        allowed_regions: "#bean:allowedRegions"
+- route:
+    from:
+      uri: direct:checkFromTrustedNetwork
+      steps:
+        - to:
+            uri: openfga:check
+            parameters:
+              storeId: "{{fga.store}}"
+              relation: reader
+              user: "user:${exchangeProperty.CamelKeycloakTokenSubject}"
+              object: "document:${header.documentId}"
+              conditionContext: "#networkContext"

Review Comment:
   🐛 **`steps:` must be a sibling of `from:`, not nested inside it**
   
   `steps` is indented at 6 spaces (child of `from:`), but it must be at 4 
spaces (sibling of `from:`) in the Camel YAML DSL. The route will silently have 
no steps as written.
   
   ```suggestion
   - route:
       from:
         uri: direct:checkFromTrustedNetwork
       steps:
         - to:
             uri: openfga:check
             parameters:
               storeId: "{{fga.store}}"
               relation: reader
               user: "user:${exchangeProperty.CamelKeycloakTokenSubject}"
               object: "document:${header.documentId}"
               conditionContext: "#networkContext"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to