Skip to content

Authentication/Authorization API changes for preview.7 #42481

Closed
@DamianEdwards

Description

@DamianEdwards

Following changes to be made to the authentication and authorization configuration APIs and behaviors:

- [ ] Change the WebApplicationBuilder.Authentication property to be a method AddAuthentication() with the same overloads as IServiceCollection.AddAuthentication()
- [ ] Add WebApplicationBuilder.AddAuthorization() method that is functional equivalent of IServiceCollection.AddAuthorizationBuilder()

  • Remove Authentication property from WebApplicationBuilder
  • Remove binding of AuthenticationOptions.DefaultScheme from configuration (and dotnet user-jwts setting it in applicationSettings.Development.json)
  • When there is only a single AuthN scheme added, set AuthenticationOptions.DefaultPolicy to that scheme, and add a new bool property AuthenticationOptions.DisableAutoDefaultScheme to enable disabling this behavior
  • Auto-add AuthN and AuthZ middleware if any AuthN scheme is added in all hosts (not just WebApplicationBuilder) WebApplicationBuilder and add new bool option to the various hosting options/APIs to enable disabling this behavior, e.g. WebApplicationOptions.DisableAutoAddAuthMiddleware
    • This behavior should apply whether adding AuthN schemes via IServiceCollection.AddAuthentication() or WebApplicationBuilder.AddAuthentication(), etc.

Metadata

Metadata

Assignees

Labels

area-authIncludes: Authn, Authz, OAuth, OIDC, Bearerarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbreaking-changeThis issue / pr will introduce a breaking change, when resolved / merged.feature-minimal-hosting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions