Move Microsoft.AspNetCore.Authorization.Policy types (#9492)
This commit is contained in:
parent
4914462c34
commit
7669cf0d03
|
|
@ -117,7 +117,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
{
|
||||
services.AddAuthenticationCore();
|
||||
services.AddAuthorization();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Transient<IApplicationModelProvider, AuthorizationApplicationModelProvider>());
|
||||
|
|
|
|||
|
|
@ -629,7 +629,6 @@ namespace Microsoft.AspNetCore.Mvc.Authorization
|
|||
serviceCollection.AddLogging();
|
||||
serviceCollection.AddSingleton(auth.Object);
|
||||
serviceCollection.AddAuthorization();
|
||||
serviceCollection.AddAuthorizationPolicyEvaluator();
|
||||
registerServices?.Invoke(serviceCollection);
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
|
||||
<Compile Include="Microsoft.AspNetCore.Authorization.netcoreapp3.0.cs" />
|
||||
<Reference Include="Microsoft.AspNetCore.Authentication.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
<Reference Include="Microsoft.Extensions.Options" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ namespace Microsoft.AspNetCore.Authorization
|
|||
public virtual System.Threading.Tasks.Task HandleAsync(Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext context) { throw null; }
|
||||
protected abstract System.Threading.Tasks.Task HandleRequirementAsync(Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext context, TRequirement requirement, TResource resource);
|
||||
}
|
||||
public partial class AuthorizationMiddleware
|
||||
{
|
||||
public AuthorizationMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider policyProvider) { }
|
||||
public System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
|
||||
}
|
||||
public partial class AuthorizationOptions
|
||||
{
|
||||
public AuthorizationOptions() { }
|
||||
|
|
@ -211,6 +216,45 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure
|
|||
protected override System.Threading.Tasks.Task HandleRequirementAsync(Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext context, Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement requirement) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.AspNetCore.Authorization.Policy
|
||||
{
|
||||
public partial interface IPolicyEvaluator
|
||||
{
|
||||
System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticateResult> AuthenticateAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Http.HttpContext context);
|
||||
System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult> AuthorizeAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Authentication.AuthenticateResult authenticationResult, Microsoft.AspNetCore.Http.HttpContext context, object resource);
|
||||
}
|
||||
public partial class PolicyAuthorizationResult
|
||||
{
|
||||
internal PolicyAuthorizationResult() { }
|
||||
public bool Challenged { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public bool Forbidden { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public bool Succeeded { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Challenge() { throw null; }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Forbid() { throw null; }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Success() { throw null; }
|
||||
}
|
||||
public partial class PolicyEvaluator : Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator
|
||||
{
|
||||
public PolicyEvaluator(Microsoft.AspNetCore.Authorization.IAuthorizationService authorization) { }
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||
public virtual System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticateResult> AuthenticateAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||
public virtual System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult> AuthorizeAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Authentication.AuthenticateResult authenticationResult, Microsoft.AspNetCore.Http.HttpContext context, object resource) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
public static partial class AuthorizationAppBuilderExtensions
|
||||
{
|
||||
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseAuthorization(this Microsoft.AspNetCore.Builder.IApplicationBuilder app) { throw null; }
|
||||
}
|
||||
public static partial class AuthorizationEndpointConventionBuilderExtensions
|
||||
{
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder) { throw null; }
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params Microsoft.AspNetCore.Authorization.IAuthorizeData[] authorizeData) { throw null; }
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params string[] policyNames) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static partial class AuthorizationServiceCollectionExtensions
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Microsoft.AspNetCore.Authorization.Policy
|
||||
{
|
||||
internal class AuthorizationPolicyMarkerService
|
||||
internal class AuthorizationMarkerService
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization.Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization.Policy;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
|
|
@ -31,6 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.TryAdd(ServiceDescriptor.Transient<IAuthorizationEvaluator, DefaultAuthorizationEvaluator>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IAuthorizationHandlerContextFactory, DefaultAuthorizationHandlerContextFactory>());
|
||||
services.TryAddEnumerable(ServiceDescriptor.Transient<IAuthorizationHandler, PassThroughAuthorizationHandler>());
|
||||
services.TryAddSingleton<AuthorizationMarkerService>();
|
||||
|
||||
// Policy
|
||||
services.TryAdd(ServiceDescriptor.Transient<IPolicyEvaluator, PolicyEvaluator>());
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core authorization classes.
|
||||
|
|
@ -14,7 +14,13 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute</Description>
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="$(SharedSourceRoot)SecurityHelper\**\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.Authentication.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
<Reference Include="Microsoft.Extensions.Options" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ namespace Microsoft.AspNetCore.Builder
|
|||
{
|
||||
// Verify that AddAuthorizationPolicy was called before calling UseAuthorization
|
||||
// We use the AuthorizationPolicyMarkerService to ensure all the services were added.
|
||||
if (app.ApplicationServices.GetService(typeof(AuthorizationPolicyMarkerService)) == null)
|
||||
if (app.ApplicationServices.GetService(typeof(AuthorizationMarkerService)) == null)
|
||||
{
|
||||
throw new InvalidOperationException(Resources.FormatException_UnableToFindServices(
|
||||
nameof(IServiceCollection),
|
||||
nameof(PolicyServiceCollectionExtensions.AddAuthorizationPolicyEvaluator),
|
||||
nameof(AuthorizationServiceCollectionExtensions.AddAuthorization),
|
||||
"ConfigureServices(...)"));
|
||||
}
|
||||
}
|
||||
|
|
@ -4,5 +4,6 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
// Microsoft.AspNetCore.Http.Abstractions
|
||||
[assembly: TypeForwardedTo(typeof(IAuthorizeData))]
|
||||
[assembly: TypeForwardedTo(typeof(IAllowAnonymous))]
|
||||
|
|
|
|||
|
|
@ -52,6 +52,20 @@ namespace Microsoft.AspNetCore.Authorization
|
|||
internal static string FormatException_RoleRequirementEmpty()
|
||||
=> GetString("Exception_RoleRequirementEmpty");
|
||||
|
||||
/// <summary>
|
||||
/// Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.
|
||||
/// </summary>
|
||||
internal static string Exception_UnableToFindServices
|
||||
{
|
||||
get => GetString("Exception_UnableToFindServices");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.
|
||||
/// </summary>
|
||||
internal static string FormatException_UnableToFindServices(object p0, object p1, object p2)
|
||||
=> string.Format(CultureInfo.CurrentCulture, GetString("Exception_UnableToFindServices"), p0, p1, p2);
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
|
|
|||
|
|
@ -126,4 +126,7 @@
|
|||
<data name="Exception_RoleRequirementEmpty" xml:space="preserve">
|
||||
<value>At least one role must be specified.</value>
|
||||
</data>
|
||||
<data name="Exception_UnableToFindServices" xml:space="preserve">
|
||||
<value>Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -6,8 +6,5 @@
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
|
||||
<Compile Include="Microsoft.AspNetCore.Authorization.Policy.netcoreapp3.0.cs" />
|
||||
<Reference Include="Microsoft.AspNetCore.Authorization" />
|
||||
<Reference Include="Microsoft.AspNetCore.Authentication.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,57 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Authorization
|
||||
{
|
||||
public partial class AuthorizationMiddleware
|
||||
{
|
||||
public AuthorizationMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider policyProvider) { }
|
||||
public System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.AspNetCore.Authorization.Policy
|
||||
{
|
||||
public partial interface IPolicyEvaluator
|
||||
{
|
||||
System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticateResult> AuthenticateAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Http.HttpContext context);
|
||||
System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult> AuthorizeAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Authentication.AuthenticateResult authenticationResult, Microsoft.AspNetCore.Http.HttpContext context, object resource);
|
||||
}
|
||||
public partial class PolicyAuthorizationResult
|
||||
{
|
||||
internal PolicyAuthorizationResult() { }
|
||||
public bool Challenged { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public bool Forbidden { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public bool Succeeded { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Challenge() { throw null; }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Forbid() { throw null; }
|
||||
public static Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult Success() { throw null; }
|
||||
}
|
||||
public partial class PolicyEvaluator : Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator
|
||||
{
|
||||
public PolicyEvaluator(Microsoft.AspNetCore.Authorization.IAuthorizationService authorization) { }
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||
public virtual System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticateResult> AuthenticateAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||
public virtual System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult> AuthorizeAsync(Microsoft.AspNetCore.Authorization.AuthorizationPolicy policy, Microsoft.AspNetCore.Authentication.AuthenticateResult authenticationResult, Microsoft.AspNetCore.Http.HttpContext context, object resource) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
public static partial class AuthorizationAppBuilderExtensions
|
||||
{
|
||||
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseAuthorization(this Microsoft.AspNetCore.Builder.IApplicationBuilder app) { throw null; }
|
||||
}
|
||||
public static partial class AuthorizationEndpointConventionBuilderExtensions
|
||||
{
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder) { throw null; }
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params Microsoft.AspNetCore.Authorization.IAuthorizeData[] authorizeData) { throw null; }
|
||||
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params string[] policyNames) { throw null; }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static partial class PolicyServiceCollectionExtensions
|
||||
{
|
||||
[System.ObsoleteAttribute("AddAuthorizationPolicyEvaluator is obsolete and will be removed in a future release. Use AddAuthorization instead.")]
|
||||
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthorizationPolicyEvaluator(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core authorization policy helper classes.</Description>
|
||||
|
|
@ -9,15 +9,8 @@
|
|||
<PackageTags>aspnetcore;authorization</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="$(SharedSourceRoot)SecurityHelper\**\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.Authorization" />
|
||||
<Reference Include="Microsoft.AspNetCore.Authentication.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
|
||||
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
|
||||
[Obsolete("AddAuthorizationPolicyEvaluator is obsolete and will be removed in a future release. Use AddAuthorization instead.")]
|
||||
public static IServiceCollection AddAuthorizationPolicyEvaluator(this IServiceCollection services)
|
||||
{
|
||||
if (services == null)
|
||||
|
|
@ -25,8 +26,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
}
|
||||
|
||||
services.AddAuthorization();
|
||||
services.TryAddSingleton<AuthorizationPolicyMarkerService>();
|
||||
services.TryAdd(ServiceDescriptor.Transient<IPolicyEvaluator, PolicyEvaluator>());
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization.Policy;
|
||||
|
||||
// Microsoft.AspNetCore.Authorization
|
||||
[assembly: TypeForwardedTo(typeof(IPolicyEvaluator))]
|
||||
[assembly: TypeForwardedTo(typeof(PolicyAuthorizationResult))]
|
||||
[assembly: TypeForwardedTo(typeof(PolicyEvaluator))]
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
// <auto-generated />
|
||||
namespace Microsoft.AspNetCore.Authorization.Policy
|
||||
{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.AspNetCore.Authorization.Policy.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.
|
||||
/// </summary>
|
||||
internal static string Exception_UnableToFindServices
|
||||
{
|
||||
get => GetString("Exception_UnableToFindServices");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.
|
||||
/// </summary>
|
||||
internal static string FormatException_UnableToFindServices(object p0, object p1, object p2)
|
||||
=> string.Format(CultureInfo.CurrentCulture, GetString("Exception_UnableToFindServices"), p0, p1, p2);
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Exception_UnableToFindServices" xml:space="preserve">
|
||||
<value>Unable to find the required services. Please add all the required services by calling '{0}.{1}' inside the call to '{2}' in the application startup code.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Authorization.Test
|
|||
// Assert
|
||||
Assert.Equal(
|
||||
"Unable to find the required services. Please add all the required services by calling " +
|
||||
"'IServiceCollection.AddAuthorizationPolicyEvaluator' inside the call to 'ConfigureServices(...)' " +
|
||||
"'IServiceCollection.AddAuthorization' inside the call to 'ConfigureServices(...)' " +
|
||||
"in the application startup code.",
|
||||
ex.Message);
|
||||
}
|
||||
|
|
@ -74,7 +74,9 @@ namespace Microsoft.AspNetCore.Authorization.Test
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
services.AddLogging();
|
||||
services.AddSingleton(authenticationService);
|
||||
|
||||
|
|
|
|||
|
|
@ -371,7 +371,6 @@ namespace Microsoft.AspNetCore.Authorization.Test
|
|||
serviceCollection.AddOptions();
|
||||
serviceCollection.AddLogging();
|
||||
serviceCollection.AddAuthorization();
|
||||
serviceCollection.AddAuthorizationPolicyEvaluator();
|
||||
registerServices?.Invoke(serviceCollection);
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
|
@ -411,4 +410,4 @@ namespace Microsoft.AspNetCore.Authorization.Test
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test
|
|||
{
|
||||
var services = new ServiceCollection()
|
||||
.AddAuthorization()
|
||||
.AddAuthorizationPolicyEvaluator()
|
||||
.AddLogging()
|
||||
.AddOptions();
|
||||
setupServices?.Invoke(services);
|
||||
|
|
@ -206,4 +205,4 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,8 +96,6 @@ namespace FunctionalTests
|
|||
}
|
||||
};
|
||||
});
|
||||
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
public static IServiceCollection AddConnections(this IServiceCollection services)
|
||||
{
|
||||
services.AddRouting();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization();
|
||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<ConnectionOptions>, ConnectionOptionsSetup>());
|
||||
services.TryAddSingleton<HttpConnectionDispatcher>();
|
||||
services.TryAddSingleton<HttpConnectionManager>();
|
||||
|
|
|
|||
|
|
@ -1360,7 +1360,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
var services = new ServiceCollection();
|
||||
services.AddOptions();
|
||||
services.AddSingleton<TestConnectionHandler>();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization(o =>
|
||||
{
|
||||
o.AddPolicy("test", policy => policy.RequireClaim(ClaimTypes.NameIdentifier));
|
||||
|
|
@ -1406,7 +1405,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
var services = new ServiceCollection();
|
||||
services.AddOptions();
|
||||
services.AddSingleton<TestConnectionHandler>();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization(o =>
|
||||
{
|
||||
o.AddPolicy("test", policy => policy.RequireClaim(ClaimTypes.NameIdentifier));
|
||||
|
|
@ -1455,7 +1453,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
var services = new ServiceCollection();
|
||||
services.AddOptions();
|
||||
services.AddSingleton<TestConnectionHandler>();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization(o =>
|
||||
{
|
||||
o.AddPolicy("test", policy =>
|
||||
|
|
@ -1515,7 +1512,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
var services = new ServiceCollection();
|
||||
services.AddOptions();
|
||||
services.AddSingleton<TestConnectionHandler>();
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization(o =>
|
||||
{
|
||||
o.AddPolicy("test", policy =>
|
||||
|
|
@ -1610,7 +1606,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
policy.AddAuthenticationSchemes("Default");
|
||||
});
|
||||
});
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddLogging();
|
||||
services.AddAuthenticationCore(o =>
|
||||
{
|
||||
|
|
@ -1672,7 +1667,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
policy.AddAuthenticationSchemes("Default");
|
||||
});
|
||||
});
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddLogging();
|
||||
services.AddAuthenticationCore(o =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
}).AddCookie();
|
||||
|
||||
services.AddAuthorizationPolicyEvaluator();
|
||||
services.AddAuthorization();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
|
|
|
|||
Loading…
Reference in New Issue