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 _cookieName;
|
||||||
private string _formFieldName = AntiforgeryTokenFieldName;
|
private string _formFieldName = AntiforgeryTokenFieldName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default cookie prefix, which is ".AspNetCore.Antiforgery.".
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DefaultCookiePrefix = ".AspNetCore.Antiforgery.";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the name of the cookie that is used by the antiforgery system.
|
/// Specifies the name of the cookie that is used by the antiforgery system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <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>
|
/// </remarks>
|
||||||
public string CookieName
|
public string CookieName
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
|
||||||
if (options.CookieName == null)
|
if (options.CookieName == null)
|
||||||
{
|
{
|
||||||
var applicationId = dataProtectionOptions.ApplicationDiscriminator ?? string.Empty;
|
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
|
public class AntiforgeryOptionsSetupTest
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("HelloWorldApp", "tGmK82_ckDw")]
|
[InlineData("HelloWorldApp", ".AspNetCore.Antiforgery.tGmK82_ckDw")]
|
||||||
[InlineData("TodoCalendar", "7mK1hBEBwYs")]
|
[InlineData("TodoCalendar", ".AspNetCore.Antiforgery.7mK1hBEBwYs")]
|
||||||
public void AntiforgeryOptionsSetup_SetsDefaultCookieName_BasedOnApplicationId(
|
public void AntiforgeryOptionsSetup_SetsDefaultCookieName_BasedOnApplicationId(
|
||||||
string applicationId,
|
string applicationId,
|
||||||
string expectedCookieName)
|
string expectedCookieName)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue