elsa-workflows / elsa-workflows/elsa-core
HttpEndpoint does not use Policy when stimulated via bookmark
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
When using a HttpEndpoint in a Sequence with CanStartWorkflow = false, the Bookmark created does not contain the Policy and Authorization of the HttpEndpoint and can therefore be activated without the correct authorzation handler being run.
## Steps to Reproduce
When making a workflow which uses a HttpEndpoint in the middle with a authorization policy defined that looks like this a bit simplified:
```
builder.Root = new Sequence
{
Activities =
{
new ReceiveMasstransitMessageActivity(new Input(nameof(MasstransitMessage)))
{
CanStartWorkflow = true
},
new StartExternalServiceActivity()
{
},
new HttpEndpoint
{
Authorize = new Input(true),
Policy = new Input("ExternalServiceCallback"),
Path = new Input($"externalService/callback/{CallbackEndpoint}"),
CanStartWorkflow = false,
},
new ExternalServiceCallbackActivity()
{
},
}
```
The bookmark stored in the database does not contain a Policy and has Authorize set to false. It will also not run our custom
Setting CanStartWorkflow of the HttpEndPoint to true will run the authorization handler, but also restart the workflow, and is clearly not the intended use.
Workflow json taken from database:
```{"activities":[{"eventType":{"typeName":"String","expression":{"type":"Literal","value":"ISummarizingInvoiceProcurationFlowStartedIntegrationEvent"}},"output":null,"result":null,"id":"ReceiveIntegrationEventActivity1","nodeId":"Workflow1:Sequence1:ReceiveIntegrationEventActivity1","name":null,"type":"Rigger.WorkflowCore.Activities.IntegrationEvents.Activities.ReceiveIntegrationEvent.ReceiveIntegrationEventActivity","version":1,"customProperties":{"source":"SummarizeInvoiceForBudgetHolderWorkflow.cs:40","canStartWorkflow":true},"metadata":{}},{"processId":{"typeName":"String","expression":{"type":"Literal","value":"summarize-invoice-v2"}},"integration":{"typeName":"String","expression":{"type":"Literal","value":"budgetholder"}},"endpoint":{"typeName":"String","expression":{"type":"Literal","value":"SummarizeInvoice"}},"tenantUrl":{"typeName":"String"},"externalId":{"typeName":"String"},"inputData":{"typeName":"ObjectMap"},"id":"StartAcitFlowActivity1","nodeId":"Workflow1:Sequence1:StartAcitFlowActivity1","name":null,"type":"Rigger.Workflow.Activities.Acit.StartAcitFlow.StartAcitFlowActivity","version":1,"customProperties":{},"metadata":{}},{"path":{"typeName":"String","expression":{"type":"Literal","value":"acit/callback/SummarizeInvoice"}},"supportedMethods":{"typeName":"List\u003CString\u003E","expression":{"type":"Literal","value":["POST"]}},"authorize":{"typeName":"Boolean","expression":{"type":"Literal","value":true}},"policy":{"typeName":"String","expression":{"type":"Literal","value":"AcitCallback"}},"requestTimeout":null,"requestSizeLimit":null,"fileSizeLimit":null,"allowedFileExtensions":null,"blockedFileExtensions":null,"allowedMimeTypes":null,"exposeRequestTooLargeOutcome":false,"exposeFileTooLargeOutcome":false,"exposeInvalidFileExtensionOutcome":false,"exposeInvalidFileMimeTypeOutcome":false,"parsedContent":{"typeName":"Object","memoryReference":{"id":"Workflow1:variable-1"}},"files":null,"routeData":null,"queryStringData":null,"headers":null,"result":null,"id":"HttpEndpoint1","nodeId":"Workflow1:Sequence1:HttpEndpoint1","name":null,"type":"Elsa.HttpEndpoint","version":1,"customProperties":{"source":"SummarizeInvoiceForBudgetHolderWorkflow.cs:62","canStartWorkflow":false},"metadata":{}},{"output":{"typeName":"Rigger.Workflow.Activities.Acit.AcitCallback.FlowExecutionResult, Rigger.Workflow.Activities.Acit","memoryReference":{"id":"Workflow1:variable-2"}},"requestBody":{"typeName":"Rigger.Workflow.Activities.Acit.AcitCallback.AcitCallbackModel, Rigger.Workflow.Activities.Acit"},"id":"AcitCallbackActivity1","nodeId":"Workflow1:Sequence1:AcitCallbackActivity1","name":null,"type":"Rigger.Workflow.Activities.Acit.AcitCallback.AcitCallbackActivity","version":1,"customProperties":{},"metadata":{}},{"operationTypeName":{"typeName":"String","expression":{"type":"Literal","value":"IAddInvoiceProcurationFlowAiSummaryOperation"}},"operationJsonBody":{"typeName":"String"},"id":"ExecuteDomainOperationActivity1","nodeId":"Workflow1:Sequence1:ExecuteDomainOperationActivity1","name":null,"type":"Rigger.WorkflowCore.Activities.DomainOperations.Activities.ExecuteDomainOperation.ExecuteDomainOperationActivity","version":1,"customProperties":{},"metadata":{}}],"variables":[],"id":"Sequence1","nodeId":"Workflow1:Sequence1","type":"Elsa.Sequence","version":1,"customProperties":{"source":"SummarizeInvoiceForBudgetHolderWorkflow.cs:36"},"metadata":{}}
```
6. **Additional Configuration**:
Running with MongoDb, Masstransit and using a custom authorization policy.
Providing a comprehensive and clear description will greatly assist in diagnosing the problem quickly and accurately. If you're unable to share some of the requested information publicly, please note that, and we can arrange for secure information transfer.
## Expected Behavior
The created Bookmark contains the policy and the authorization handler is called when receiving the http request .
## Actual Behavior
The bookmark doesn't contain the policy after indexing and the HttpEndpoint activity is executed without authorization being checked.
## Environment
- **Elsa Package Version**: 3.5.0
- **Operating System**: Windows 11
## Troubleshooting Attempts
Deepwiki suggested making my own implementation from HttpEndpointBase, I'll look at that.
Contributor guide
Assessment
This issue has not been assessed yet.