Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

AuthorizationBuilder Class

Definition

Namespace:
Microsoft.AspNetCore.Authorization
Assembly:
Microsoft.AspNetCore.Authorization.dll
Package:
Microsoft.AspNetCore.Authorization v10.0.0
Package:
Microsoft.AspNetCore.Authorization v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Authorization v7.0.5
Package:
Microsoft.AspNetCore.Authorization v8.0.19
Package:
Microsoft.AspNetCore.Authorization v9.0.8
Source:
AuthorizationBuilder.cs
Source:
AuthorizationBuilder.cs
Source:
AuthorizationBuilder.cs
Source:
AuthorizationBuilder.cs
Source:
AuthorizationBuilder.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Used to configure authorization

public class AuthorizationBuilder
type AuthorizationBuilder = class
Public Class AuthorizationBuilder
Inheritance
AuthorizationBuilder

Constructors

Name Description
AuthorizationBuilder(IServiceCollection)

Initializes a new instance of AuthorizationBuilder.

Properties

Name Description
Services

The services being configured.

Methods

Name Description
AddDefaultPolicy(String, Action<AuthorizationPolicyBuilder>)

Add a policy that is built from a delegate with the provided name and used as the DefaultPolicy.

AddDefaultPolicy(String, AuthorizationPolicy)

Add a policy that is built from a delegate with the provided name and used as the default policy.

AddFallbackPolicy(String, Action<AuthorizationPolicyBuilder>)

Add a policy that is built from a delegate with the provided name and used as the FallbackPolicy.

AddFallbackPolicy(String, AuthorizationPolicy)

Add a policy that is built from a delegate with the provided name and used as the FallbackPolicy.

AddPolicy(String, Action<AuthorizationPolicyBuilder>)

Add a policy that is built from a delegate with the provided name.

AddPolicy(String, AuthorizationPolicy)

Adds a AuthorizationPolicy which can be used by IAuthorizationService.

SetDefaultPolicy(AuthorizationPolicy)

Sets the default authorization policy. Defaults to require authenticated users.

SetFallbackPolicy(AuthorizationPolicy)

Sets the fallback authorization policy used by CombineAsync(IAuthorizationPolicyProvider, IEnumerable<IAuthorizeData>) when no IAuthorizeData have been provided. As a result, the AuthorizationMiddleware uses the fallback policy if there are no IAuthorizeData instances for a resource. If a resource has any IAuthorizeData then they are evaluated instead of the fallback policy. By default the fallback policy is null, and usually will have no effect unless you have the AuthorizationMiddleware in your pipeline. It is not used in any way by the default IAuthorizationService.

SetInvokeHandlersAfterFailure(Boolean)

Determines whether authorization handlers should be invoked after HasFailed. Defaults to true.

Applies to


Feedback

Was this page helpful?