How to modify response from workflow instances journal activity data?? #1577
-
|
When I want to see the workflow instances activity data example inbound request in HTTP endpoint it have some sensitive data. So I want to sensor it before response (not modify it on WorkflowExecutionLogRecords table). What the best way to do it?? Best regards. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
You can't easily do it right now, but it makes sense to enable this. To mask data before it gets persisted, we could introduce a filter that you implement. public class PIIFilter : IWorkflowJournalFilter
{
public void Apply(WorkflowJournalFilterContext context)
{
var activityTypeName = context.ActivityBlueprint.Type;
var journalData = context.Data; // This is of type JObject.
// Ignore everything that does not concern HTTP Endpoints.
if(activityTypeName != nameof(HttpEndpoint))
return data;
var httpRequestModel = journalData.GetValue<HttpRequestModel>("Inbound Request"); // Get the stored HTTP request model.
// Mask aspects of the HTTP request.
httpRequestModel.RawBody = Mask(httpRequestModel.RawBody);
httpRequestModel.Body = Mask(httpRequestModel.Body);
journalData["Inbound Request"] = JObject.FromObject(httpRequestModel);
return;
// Alternatively, you could concert the HTTP request model to a JObject and remove certain parts entirely:
var httpRequestModelJObject = JObject.FromObject(httpRequestModel);
// Remove the Body field.
httpRequestModelJObject.Remove("Body");
// Mask the RawBody field (perhaps easier to process because it's a plain string).
httpRequestModelJObject["RawBody"] = Mask(httpRequestModelJObject["RawBody"]);
}
}Would something like that work for your use case? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your suggestion., Now, I use
because the workflow instance dashboard will call data from above Api (management Api). |
Beta Was this translation helpful? Give feedback.
Thank you for your suggestion.,
Now, I use
IActionFilterto process the executed event (OnActionExecuted) and register it in global config. I modify the data from 2 requestsElsa.Server.Api.Endpoints.WorkflowInstances.Get-> to get workflow instanceElsa.Server.Api.Endpoints.WorkflowExecutionLog.Get-> to get workflow execution logbecause the workflow instance dashboard will call data from above Api (management Api).
Now, I usually modify data from
HttpRequestModeland raw content (json string).