Merge pull request #9428 from umbraco/netcore/task/6666-auth-policies
Migrate authorization filters to authorization policies
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -8,9 +7,7 @@ using Smidge;
|
||||
using Smidge.Nuglify;
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Infrastructure.Logging.Serilog.Enrichers;
|
||||
using Umbraco.Web.Common.Middleware;
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Web.BackOffice.Authorization;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddUmbracoCommonAuthorizationPolicies(this IServiceCollection services)
|
||||
{
|
||||
// TODO: Should this only exist in the back office project? These really are only ever used for the back office AFAIK
|
||||
// If it is moved it should only target the back office scheme
|
||||
|
||||
services.AddSingleton<IAuthorizationHandler, FeatureAuthorizeHandler>();
|
||||
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
options.AddPolicy(AuthorizationPolicies.UmbracoFeatureEnabled, policy =>
|
||||
policy.Requirements.Add(new FeatureAuthorizeRequirement()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user