[Antiforgery][Components][CORS] Remove obsolete APIs (#7459)
#7325 #7319 #7324
This commit is contained in:
parent
58e6d78549
commit
dbf746d210
|
|
@ -82,69 +82,5 @@ namespace Microsoft.AspNetCore.Antiforgery
|
|||
/// the X-Frame-Options header will not be generated for the response.
|
||||
/// </summary>
|
||||
public bool SuppressXFrameOptionsHeader { get; set; }
|
||||
|
||||
#region Obsolete API
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// This property is obsolete and will be removed in a future version. The recommended alternative is <seealso cref="CookieBuilder.Name"/> on <see cref="Cookie"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Specifies the name of the cookie that is used by the antiforgery system.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If an explicit name is not provided, the system will automatically generate a
|
||||
/// unique name that begins with <see cref="DefaultCookiePrefix"/>.
|
||||
/// </remarks>
|
||||
[Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Name) + ".")]
|
||||
public string CookieName { get => Cookie.Name; set => Cookie.Name = value; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// This property is obsolete and will be removed in a future version. The recommended alternative is <seealso cref="CookieBuilder.Path"/> on <see cref="Cookie"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The path set on the cookie. If set to <c>null</c>, the "path" attribute on the cookie is set to the current
|
||||
/// request's <see cref="HttpRequest.PathBase"/> value. If the value of <see cref="HttpRequest.PathBase"/> is
|
||||
/// <c>null</c> or empty, then the "path" attribute is set to the value of <see cref="CookieOptions.Path"/>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Path) + ".")]
|
||||
public PathString? CookiePath { get => Cookie.Path; set => Cookie.Path = value; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// This property is obsolete and will be removed in a future version. The recommended alternative is <seealso cref="CookieBuilder.Domain"/> on <see cref="Cookie"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The domain set on the cookie. By default its <c>null</c> which results in the "domain" attribute not being set.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")]
|
||||
public string CookieDomain { get => Cookie.Domain; set => Cookie.Domain = value; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// This property is obsolete and will be removed in a future version.
|
||||
/// The recommended alternative is to set <seealso cref="CookieBuilder.SecurePolicy"/> on <see cref="Cookie"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <c>true</c> is equivalent to <see cref="CookieSecurePolicy.Always"/>.
|
||||
/// <c>false</c> is equivalent to <see cref="CookieSecurePolicy.None"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Specifies whether SSL is required for the antiforgery system
|
||||
/// to operate. If this setting is 'true' and a non-SSL request
|
||||
/// comes into the system, all antiforgery APIs will fail.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is to set " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")]
|
||||
public bool RequireSsl
|
||||
{
|
||||
get => Cookie.SecurePolicy == CookieSecurePolicy.Always;
|
||||
set => Cookie.SecurePolicy = value ? CookieSecurePolicy.Always : CookieSecurePolicy.None;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
|
|||
var httpContext = GetHttpContext();
|
||||
var options = new AntiforgeryOptions
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
// obsolete property still forwards to correctly to the new API
|
||||
RequireSsl = true
|
||||
#pragma warning restore CS0618
|
||||
Cookie = new CookieBuilder
|
||||
{
|
||||
SecurePolicy = CookieSecurePolicy.Always
|
||||
}
|
||||
};
|
||||
var antiforgery = GetAntiforgery(httpContext, options);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
// 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 Microsoft.JSInterop;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides mechanisms for converting between .NET objects and JSON strings.
|
||||
/// </summary>
|
||||
[Obsolete("Use Microsoft.JSInterop.Json instead.")]
|
||||
public static class JsonUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the value as a JSON string.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to serialize.</param>
|
||||
/// <returns>The JSON string.</returns>
|
||||
[Obsolete("Use Microsoft.JSInterop.Json.Serialize instead.")]
|
||||
public static string Serialize(object value)
|
||||
=> Json.Serialize(value);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the JSON string, creating an object of the specified generic type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of object to create.</typeparam>
|
||||
/// <param name="json">The JSON string.</param>
|
||||
/// <returns>An object of the specified type.</returns>
|
||||
[Obsolete("Use Microsoft.JSInterop.Json.Deserialize<T> instead.")]
|
||||
public static T Deserialize<T>(string json)
|
||||
=> Json.Deserialize<T>(json);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,16 +22,6 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
|
|||
private readonly CorsOptions _options;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="CorsService"/>.
|
||||
/// </summary>
|
||||
/// <param name="options">The option model representing <see cref="CorsOptions"/>.</param>
|
||||
[Obsolete("This constructor is obsolete and will be removed in a future version.")]
|
||||
public CorsService(IOptions<CorsOptions> options)
|
||||
: this(options, loggerFactory: NullLoggerFactory.Instance)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="CorsService"/>.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue