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
MIT License
293 stars 49 forks source link

SignalR Negotiate | build compile issue #114

Open robcwaldron opened 4 years ago

robcwaldron commented 4 years ago

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

mdg215199 commented 4 years ago

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)

robcwaldron commented 4 years ago

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

robcwaldron commented 4 years ago

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) )

robcwaldron commented 4 years ago

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

mdg215199 commented 4 years ago

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).

robcwaldron commented 4 years ago

Hey @mdg215199

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

image

image

A

JamesRandall commented 4 years ago

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.

robcwaldron commented 4 years ago

Thanks @JamesRandall . Testing this now

robcwaldron commented 4 years ago

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

robcwaldron commented 4 years ago

@JamesRandall - 5.6 still seems to be referenced?

image

JamesRandall commented 4 years ago

Aaarrrggh. I’d checked deps too. I’ll take another look. Thanks for letting me know!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Rob Waldron notifications@github.com Sent: Thursday, January 9, 2020 10:47:47 AM To: JamesRandall/FunctionMonkey FunctionMonkey@noreply.github.com Cc: james james@accidentalfish.com; Mention mention@noreply.github.com Subject: Re: [JamesRandall/FunctionMonkey] SignalR Negotiate | build compile issue (#114)

@JamesRandallhttps://github.com/JamesRandall - 5.6 still seems to be referenced?

[image]https://user-images.githubusercontent.com/1562797/72056744-e6a49980-3318-11ea-8bb5-48aee3ec5a7a.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/JamesRandall/FunctionMonkey/issues/114?email_source=notifications&email_token=AABZVV36VAGOMFSWYTI6NVDQ43XEHA5CNFSM4KCZRNJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPVLQA#issuecomment-572478912, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABZVV3RVVBDZHR5DCMBRCLQ43XEHANCNFSM4KCZRNJQ.

JamesRandall commented 4 years ago

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

image
JamesRandall commented 4 years ago

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?

robcwaldron commented 4 years ago

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

csproj here: image

robcwaldron commented 4 years ago

@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

JamesRandall commented 4 years ago

Thanks - I’m travelling today but I’ll take a look at that ASAP.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Rob Waldron notifications@github.com Sent: Tuesday, January 14, 2020 6:57:21 AM To: JamesRandall/FunctionMonkey FunctionMonkey@noreply.github.com Cc: james james@accidentalfish.com; Mention mention@noreply.github.com Subject: Re: [JamesRandall/FunctionMonkey] SignalR Negotiate | build compile issue (#114)

@JamesRandallhttps://github.com/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]https://user-images.githubusercontent.com/1562797/72317886-61d5c900-36e6-11ea-9bba-1cae44679c71.png

Command: [image]https://user-images.githubusercontent.com/1562797/72317921-803bc480-36e6-11ea-97f5-81be7a38a6d5.png

Handler: [image]https://user-images.githubusercontent.com/1562797/72317899-6dc18b00-36e6-11ea-9cf1-0b98ca2f1e29.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/JamesRandall/FunctionMonkey/issues/114?email_source=notifications&email_token=AABZVV5JZGNRAHUZYLYRGY3Q5VH4DA5CNFSM4KCZRNJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI3MRUY#issuecomment-574015699, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABZVV47BWINXXHZA5232ADQ5VH4DANCNFSM4KCZRNJQ.