JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SignalR Negotiate | build compile issue

robcwaldron opened this issue · comments

When using the command and handlers for SignalR, the build fails to compile. This is on the latest beta build.

.Functions(functions => functions
.SignalR(signalR => signalR
.Negotiate("/negotiate")
)

image

I think you need to add the extra hub name.
.Negotiate("/negotiate", "hubName")

That way, it seems to work. On handling the handler itself so you can control the negotiate, this works
.Negotiate("/negotiate", AuthorizationTypeEnum.Anonymous, HttpMethod.Post)

Thanks, so I tried it that. I still seem to get the same error when using the handler way. Maybe I'm missing something simple?

image

Okay, I've been attempting to debug this. For more clarity, I'm using Authorization too. When I comment out the below, the issue goes away. Still trying to find what the cause is though. I'll report back if I can find it.

.Authorization(authorization => authorization
.AuthorizationDefault(AuthorizationTypeEnum.TokenValidation)
.AddOpenIdConnectTokenValidator($"https://{Domain}/oauth2/default/.well-known/oauth-authorization-server", Audience)
)

Okay, I've tracked down the issue to the handlebars template file signalrcommandnegotiate.csharp.handlebars. Not overly familiar with the behind the scenes of FunctionMonkey yet, but I'll see if I can work out what it's all doing.

image

Is the example you gave earlier, is that what you are using?

.SignalR(signalR => signalR
.Negotiate("/negotiate")

Also, what do you have set up in the csproj? As i can replicate the issue. Oh, one other question, do you need to validate your openid bearer? I tried testing on both scenarios (anonymous with no auth, and also, another with the authorization in place for http w/ anonymous on the signalr).

Hey @mdg215199

Here's the snippet from the FunctionAppConfiguration and the csproj. Yes, ideally openid is used here for validation.

image

image

A

This should be resolved as part of beta 3 - its on NuGet now. Let me know if that helps. I was able to replicate in the acceptance tests and resolve so marking this as closed. Please reopen if you continue to face issues.

There were some breaking changes in the Microsoft.IdentityModel.Tokens package and its dependencies which rather unhelpfully they have not highlighted through semver. I'd updated to 5.6 but in an underlying JWT package (also a minor version bump) they've removed a method that the SignalR binding depends on. Resolution was to downgrade to 5.5.

Thanks @JamesRandall . Testing this now

@JamesRandall - this issue still exists in beta3. It's still reporting System.Runtime.Extensions Version 4.2.2.0 is not present.

@JamesRandall - 5.6 still seems to be referenced?

image

That is very very strange. In my csproj 5.5 is definitely referenced:

image

I've just tried creating a new project and adding the packages, including the token validator - it all seems to work ok:

image

Also passes in the acceptance tests.

Could you share your csproj file?

I've just created a new project with beta4, and i'm still getting IdentityModel.Tokens 5.6.0
image

csproj here:
image

@JamesRandall - Okay, so I've tried to mock up what you've done in your screenshots. That's working fine. Where I still get this error is if I do this:

image

Command:
image

Handler:
image

Also, no matter what i do (either VS Code or Visual Studio), I still end up with IdentityModel.Token 5.6