elsa-workflows / elsa-workflows/elsa-core
Authorization with SignalR
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
Currently I see no way way to add authorization to the "WorkflowTest" feature added in 2.4 .
Not having any way to add authorization means a protected API will never be able to use the SignalR component of Elsa.
Is there any guidance on adding authorization to the SignalR component of Elsa [like there is with the http client?](https://elsa-workflows.github.io/elsa-core/docs/extensibility/extensibility-designer-plugins#intercept-outgoing-http-requests)
The code in `elsa-workflow-test-panel` simply creates a hub connection via:
```js
this.hubConnection = new HubConnectionBuilder()
.withUrl(this.serverUrl + "/hubs/workflowTest")
.build();
```
Traditionally to add authorization you would do something like:
```js
this._hubConnection = new HubConnectionBuilder()
.withUrl(hubUri, {
accessTokenFactory: () => {
// get token from somewhere
return sessionStorage.getItem('access_token');
},
})
.build();
```
The server side would probably not need an update to its method for this so long as the prefix of `hubs` is kept for all current and future SignalR connections. The reason being that one can simply intercept the `OnMessageReceived` event during JwtBearer configuration and read and set the access token this way when the request path starts with `hubs`.
Contributor guide
Assessment
This issue has not been assessed yet.