-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Remove Authentication
property from WebApplicationBuilder
#42577
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
I think we should also have the configure overload for AddAuthorization |
Good call. Updated the PR and will update the API review. |
Update on this since we weren't totally confident with the changes here. For now, we've decided to remove the top-level property altogether for .NET 7. The changes we'll be working on in #42481 make large parts of this property redundant. Update API proposal is below. Proposed APInamespace Microsoft.AspNetCore.Builder;
public sealed class WebApplicationBuilder
{
- public AuthenticationBuilder Authentication { get; }
} Usage ExamplesPrevious: var builder = WebApplication.CreateBuilder(args);
builder.Authentication.AddJwtBearer("foobar"); Now (same as .NET 6): var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication().AddJwtBearer("foobar"); |
AddAuthentiation
and AddAuthorization
methods to WebApplicationBuilderAuthentication
property from WebApplicationBuilder
API review notes:
namespace Microsoft.AspNetCore.Builder;
public sealed class WebApplicationBuilder
{
- public AuthenticationBuilder Authentication { get; }
} API Approved. |
Background and Motivation
In preview5, we introduced an
Authentication
property on theWebApplicationBuilder
that provided access to a customAuthenticationBuilder
for registering new authentication schemes onto an app. The customAuthenticationBuilder
was also responsible for automatically registering custom authentication schemes in an application.However, there's a hiccup with that particular design. In particular, when a user wants to configure global authentication options in their application, they will have to fall back to using the pre-existing
AddAuthentication
extension method on theIServiceCollection
.To remedy this, we move from an
Authentication
property to anAddAuthentication
extension method to provide the benefits of a (1) top-level authentication property/method on the WAB and (2) to make it easier to configure global authentication options and configure authentication schemes in their application in one step.We also provide a parallel
AddAuthorization
method to support the newAuthorizationBuilder
APIs introduced in preview6.Proposed API
Usage Examples
Previously:
Now:
Alternative Designs
builder.Authentication.ConfigureDefaults
methodRisks
We're shipping this update to the API in preview7 so there's limited options to iterate if we find any other problems.
The text was updated successfully, but these errors were encountered: