ASP.NET Core 3 implement IAuthorizationPolicyProvider

musium

I’ve changed the target framework of my ASP.NET Core application from .NET Core 2.2 to 3.0.

My app contains a custom auth policy provider (IAuthorizationPolicyProvider) implementation. Since .NET Core 3 the IAuthorizationPolicyProvider interface contains a new method Task<AuthorizationPolicy> GetFallbackPolicyAsync().

What is the difference between Task<AuthorizationPolicy> GetDefaultPolicyAsync(); and Task<AuthorizationPolicy> GetFallbackPolicyAsync(). And how should GetFallbackPolicyAsync be implemented? Should it be implemented like GetDefaultPolicyAsync?

Currently my class implements the GetDefaultPolicyAsync method like this:

public CustomPolicyProvider( [NotNull] IOptions<AuthorizationOptions> options )
    => _fallbackPolicyProvider = new DefaultAuthorizationPolicyProvider( options ?? throw new ArgumentNullException( nameof(options) ) );

public Task<AuthorizationPolicy> GetDefaultPolicyAsync() => _fallbackPolicyProvider.GetDefaultPolicyAsync();
RenanStr

From docs for dotnet core 3.0/3.1: docs.microsoft.com

public Task<AuthorizationPolicy> GetFallbackPolicyAsync()
{
    return Task.FromResult<AuthorizationPolicy>(null);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to implement Permission Based Access Control with Asp.Net Core

How do I implement a checkbox list in ASP.NET Core?

Implement HTTP Cache (ETag) in ASP.NET Core Web API

How to correctly implement ExceptionFilterAttribute in ASP.NET Core

How to implement angular 4 server prerendering in ASP.NET Core

How to implement JWT Refresh Tokens in asp.net core web api (no 3rd party)?

How to implement machineKey in ASP.NET Core 2.0

Implement ADO connection in ASP.Net Core

Safe way to implement a "Fire and Forget" method on ASP.NET Core

Implement Pagination in ASP.NET Core 2.1 Web API

Implement Ooui on Asp.net core

Implement ASP.Net Core identity PasswordHash on Full framework Project

How to implement pagination in asp.net core razor pages

Implement OrganizationUnit filter in ASP.NET Core

How to implement Localization ASP net CORE MVC

How to implement the IConfiguration interface in ASP.NET Core for Dapper usage?

Implement Sorting With ASP.NET Core Razor Pages

How to implement permission based authorization in ASP.net core Identity?

How to implement Identity in ASP.NET Core 2.2

How to implement custom ValidateAntiforgeryTokenAuthorizationFilter in ASP.NET Core 3.1

How to implement an ASP.NET Core controller supporting Razor and Angular?

ASP Net core - How to implement background services localization?

Implement a retry policy in asp.net core

how implement Owin pipeline using Asp.net core

ASP .Net Core get all classes that Implement interface and call their methods

How to implement resource files localization ASP-NET.core?

How to implement a setup page in ASP.NET Core?

ASP.NET Core MVC : implement Save and New functionality

How to implement search filter in ASP.NET Core Web API