Update cookie name
This commit is contained in:
parent
91f44549ac
commit
91b955e080
|
|
@ -16,11 +16,17 @@ namespace Microsoft.AspNetCore.Antiforgery
|
|||
private string _cookieName;
|
||||
private string _formFieldName = AntiforgeryTokenFieldName;
|
||||
|
||||
/// <summary>
|
||||
/// The default cookie prefix, which is ".AspNetCore.Antiforgery.".
|
||||
/// </summary>
|
||||
public static readonly string DefaultCookiePrefix = ".AspNetCore.Antiforgery.";
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the name of the cookie that is used by the antiforgery system.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If an explicit name is not provided, the system will automatically generate a name.
|
||||
/// If an explicit name is not provided, the system will automatically generate a
|
||||
/// unique name that begins with <see cref="DefaultCookiePrefix"/>.
|
||||
/// </remarks>
|
||||
public string CookieName
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
|
|||
if (options.CookieName == null)
|
||||
{
|
||||
var applicationId = dataProtectionOptions.ApplicationDiscriminator ?? string.Empty;
|
||||
options.CookieName = ComputeCookieName(applicationId);
|
||||
options.CookieName = AntiforgeryOptions.DefaultCookiePrefix + ComputeCookieName(applicationId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
|
|||
public class AntiforgeryOptionsSetupTest
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("HelloWorldApp", "tGmK82_ckDw")]
|
||||
[InlineData("TodoCalendar", "7mK1hBEBwYs")]
|
||||
[InlineData("HelloWorldApp", ".AspNetCore.Antiforgery.tGmK82_ckDw")]
|
||||
[InlineData("TodoCalendar", ".AspNetCore.Antiforgery.7mK1hBEBwYs")]
|
||||
public void AntiforgeryOptionsSetup_SetsDefaultCookieName_BasedOnApplicationId(
|
||||
string applicationId,
|
||||
string expectedCookieName)
|
||||
|
|
|
|||
Loading…
Reference in New Issue