You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "gabriel-farache (via GitHub)" <gi...@apache.org> on 2025/03/27 14:53:12 UTC

[I] Create a Custom Function to Access JWT Tokens from the Workflow [incubator-kie-issues]

gabriel-farache opened a new issue, #1899:
URL: https://github.com/apache/incubator-kie-issues/issues/1899

   Sometimes, users find it helpful to access information from a specific JWT token passed to the workflow service.
   
   SonataFlow runtime can have a custom out-of-the-box function capable of parsing and decoding these tokens so that users can access the claims in the DSL expressions. For example:
   ```
   functions:
     - name: extractUser
       type: custom
       operation: "service:org.acme.workflow.auth.JWTParserHelper::extractUser"
   states:
     - name: extractUserName
       type: operation
       actions:
         - name: extractUserAction
           functionRef:
             refName: extractUser
             arguments:
               token: "${ $WORKFLOW.headers.\"X-Authorization-acme_financial_auth\" }"
       stateDataFilter:
           output: "${ { user: .preferred_username } }"
   ```
   In this excerpt, the DSL refers to a custom Java function within the project that parses the JWT token from the header "X-Authorization-acme_financial_auth." 
   
   Later, the workflow author can access the "user" attribute to return a personalized message to the requester:
   ```
     - name: loanApproved
       type: inject
       data:
         loanApproved: true
       stateDataFilter:
         output: "${ { message: \"Congrats \\(.user)! Your loan has been approved!\", loanApproved } }"
   ```
   As a shortcut, the function can take the custom header as an input and output the [JWT Payload](https://jwt.io/introduction) in JSON format, which can be merged into the workflow data context.
   
   This function can also be added to the [Serverless Workflow Functions catalog](https://github.com/serverlessworkflow/catalog)


-- 
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: commits-unsubscribe@kie.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Create a Custom Function to Access JWT Tokens from the Workflow [incubator-kie-issues]

Posted by "gabriel-farache (via GitHub)" <gi...@apache.org>.
gabriel-farache commented on issue #1899:
URL: https://github.com/apache/incubator-kie-issues/issues/1899#issuecomment-3143639825

   @yesamer ah, ok, assign it to me then, I'll manage that. Thx!


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Create a Custom Function to Access JWT Tokens from the Workflow [incubator-kie-issues]

Posted by "gabriel-farache (via GitHub)" <gi...@apache.org>.
gabriel-farache commented on issue #1899:
URL: https://github.com/apache/incubator-kie-issues/issues/1899#issuecomment-3143603734

   @yesamer or @ricardozanini could you assign this issue to @ishanjogi89 please?


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Create a Custom Function to Access JWT Tokens from the Workflow [incubator-kie-issues]

Posted by "fjtirado (via GitHub)" <gi...@apache.org>.
fjtirado closed issue #1899: Create a Custom Function to Access JWT Tokens from the Workflow
URL: https://github.com/apache/incubator-kie-issues/issues/1899


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Create a Custom Function to Access JWT Tokens from the Workflow [incubator-kie-issues]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on issue #1899:
URL: https://github.com/apache/incubator-kie-issues/issues/1899#issuecomment-3143636441

   Hi @gabriel-farache, it looks like @ishanjogi89 is not an Apache KIE committer. As far as I know, we can assign issues to Apache KIE committers + the person which created the issue only.


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org