Ejemplo n.º 1
0
        /// <summary>
        /// Adds Umbraco back office authorization policies
        /// </summary>
        public static IUmbracoBuilder AddBackOfficeAuthorizationPolicies(this IUmbracoBuilder builder, string backOfficeAuthenticationScheme = Constants.Security.BackOfficeAuthenticationType)
        {
            builder.AddBackOfficeAuthorizationPoliciesInternal(backOfficeAuthenticationScheme);

            builder.Services.AddSingleton <IAuthorizationHandler, FeatureAuthorizeHandler>();

            builder.Services.AddAuthorization(options
                                              => options.AddPolicy(AuthorizationPolicies.UmbracoFeatureEnabled, policy
                                                                   => policy.Requirements.Add(new FeatureAuthorizeRequirement())));

            return(builder);
        }