davsclaus commented on code in PR #29138:
URL: https://github.com/apache/camel/pull/29138#discussion_r4478267368
##########
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:
Agreed with Andrea: `steps` nested under `from` is the canonical YAML DSL
form (`OutputAwareFromDefinitionDeserializer` binds `steps` as a property of
`from`), so the example is right as written. Resolving.
_Claude Code on behalf of davsclaus_
--
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]