Azure / Azure/azure-functions-host

Add support for custom authentication handlers

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

Description

Today if you try to overwrite a service that we've registered, it can cause problems. We have a fairly vague explanation of this here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection#overriding-host-services.

Customers that try to add their own authentication in a FunctionsStartup can run into odd errors later like

```
System.InvalidOperationException : No authentication handler is registered for the scheme 'ArmToken'. The registered schemes are: WebJobsAuthLevelIdentityServerAuthenticationJwt, WebJobsAuthLevelIdentityServerAuthenticationIntrospection, WebJobsAuthLevel, BearerIdentityServerAuthenticationJwt, BearerIdentityServerAuthenticationIntrospection, Bearer. Did you forget to call AddAuthentication().Add[SomeAuthHandler]("ArmToken",...)?
```

One example would be doing this in your startup:

```
builder.Services.AddAuthentication()
.AddCookie();
```

We should add a way to allow auth handlers from Startup compose with the built-in functions handlers. Or another alternative may be to prevent custom handlers from impacting `/admin` routes.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the FunctionsStartup example using AddAuthentication().AddCookie() and the linked dependency-injection documentation. Compare the built-in handlers and the /admin routes described in the issue, then define which composition behavior should be supported and how completion would be verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
authentication, backend
Issue type
Feature
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.