Azure / Azure/azure-functions-host

"AddSignalRCore()" call in a class that implements FunctionsStartup overrides Auth Policy

Open
#8,271 0 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

Not sure how often we get a case of this (@kashimiz and I have both resolved incidents caused by this) but wanted to make sure this discussion/info is noted somewhere.

## Repro

This is the repro I got last week

- V3 Inproc dotnet app
- `Startup` class that implements `FunctionsStartup`
- Add the line `builder.Services.AddSignalRCore();` to the Configure method of this class.

## Why this breaks a function app

In [this line](https://github.com/dotnet/aspnetcore/blob/ff0d53b885af0d035146041b1cba333346991040/src/SignalR/server/Core/src/SignalRDependencyInjectionExtensions.cs#L32) of `AddSignalRCore()`, an auth policy provider is added that seems to override our own. This override causes calls to endpoints like "admin/host/status" to fail.

Official docs for using SignalR with Functions do not ask users to do this -- it seems to be that some users familiar with ASP.NET Core outside of functions assumed that the programming model they are used to would work similarly with functions.

[The SignalR Extension](https://github.com/Azure/azure-functions-signalrservice-extension) already does the work needed to get the bindings working ([see here](https://github.com/Azure/azure-functions-signalrservice-extension/blob/dev/src/SignalRServiceExtension/SignalRWebJobsStartup.cs)) so the `AddSignalRCore()` call is not actually needed.

## Potential improvements

Again, unclear on how often people have run into this since our official docs (and most of the unofficial tutorials I've seen) don't tell users to wire up their SignalR functions this way, but there has been more than one incident caused by a misunderstanding of the programming model.

We could add an analyzer, add a note to emphasize not doing this somewhere, etc.

Contributor guide

Open the contributing guide

Research direction

Read the reported AddSignalRCore() behavior in SignalRDependencyInjectionExtensions.cs and compare it with SignalRWebJobsStartup.cs in the SignalR extension. Reproduce the V3 in-process FunctionsStartup scenario described here, then determine which improvement—an analyzer, documentation note, or another approach—is appropriate. Done requires an agreed scope that prevents the auth policy override.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
authentication, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.