-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IFunctionInvocationFilter.OnExecutingAsync priority versus SignalRConnectionInfo #71
Comments
Could you share your code? By the way, |
@realwanpengli The code below is the default per Microsoft documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-signalr-service Note that the
Therefore, we would expect that if we inject the header
|
|
@realwanpengli Yes, of course it is executed after the input binding and I think that's the unfortunate part as it means it is not possible to inject this value into the The use case is to allow non-App Gateway authentication to work with |
Since the arguments are binded before running into
|
I think that this is not quite as elegant, but gets the job done :) (same with the imperative binding). |
Modifing connectionInfo in |
Not sure if this is an issue for this project or https://github.com/Azure/azure-webjobs-sdk, so trying here first.
The issue is that the
SignalRConnectionInfoAttribute
binding is seemingly evaluated beforeIFunctionInvocationFilter
. The symptom is that a header added viaIFunctionInvocationFilter.OnExecutingAsync
is available in the function method, but is empty when theUserId
property is evaluated.Repro steps
Implement SignalR negotiate endpoint in Azure Functions per documented examples and specify
SignalRConnectionInfoAttribute
binding withUserId="{headers.x-my-auth-header}"
Implement interface
IFunctionInvocationFilter
and in methodOnExecutingAsync
, inject the custom header into the request.Observe that the following exception is thrown:
HttpRequest.Headers
Expected behavior
For the Functions SignalR parameter bindings to work properly for custom authentication scenarios, my understanding is that the application needs to be able to pre-process the request and extract the user information (for example, from JWT) and inject it into the headers. In order to use Users and Groups, it is necessary that the
SignalRConnectionInfo
is created with theUserId
property.The
x-ms-client-principal-id
is not set/not available unless using App Service Authentication.Actual behavior
Headers injected via execution of
IFunctionInvocationFilter.OnExecutingAsync
are not available when theSignalRConnectionInfoAttribute
is processed.Known workarounds
Workaround is possible using imperative binding.
Related information
The text was updated successfully, but these errors were encountered: