Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit c6db8e0

Browse files
committed
Updates
1 parent d989a81 commit c6db8e0

File tree

9 files changed

+20
-19
lines changed

9 files changed

+20
-19
lines changed

shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class ChunkingCookieManager
3333
/// <summary>
3434
/// The default maximum size of characters in a cookie to send back to the client.
3535
/// </summary>
36-
public const int DefaultChunkSize = 4070;
36+
public const int DefaultChunkSize = 4050;
3737

3838
private const string ChunkKeySuffix = "C";
3939
private const string ChunkCountPrefix = "chunks-";
@@ -42,7 +42,7 @@ public ChunkingCookieManager()
4242
{
4343
// Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case.
4444
// See http://browsercookielimits.x64.me/.
45-
// Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'.
45+
// Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'.
4646
ChunkSize = DefaultChunkSize;
4747
ThrowForPartialCookies = true;
4848
}
@@ -166,6 +166,7 @@ public void AppendResponseCookie(HttpContext context, string key, string value,
166166
{
167167
Domain = options.Domain,
168168
Expires = options.Expires,
169+
SameSite = (Net.Http.Headers.SameSiteMode)options.SameSite,
169170
HttpOnly = options.HttpOnly,
170171
Path = options.Path,
171172
Secure = options.Secure,

src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public CookieAuthenticationOptions()
2222
ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
2323
ExpireTimeSpan = TimeSpan.FromDays(14);
2424
SlidingExpiration = true;
25-
CookieSameSite = SameSiteEnforcementMode.Strict;
25+
CookieSameSite = SameSiteMode.Strict;
2626
CookieHttpOnly = true;
2727
CookieSecure = CookieSecurePolicy.SameAsRequest;
2828
Events = new CookieAuthenticationEvents();
@@ -61,7 +61,7 @@ public string CookieName
6161
/// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The
6262
/// default is Strict, which means the cookie is only allowed to be attached to same-site requests.
6363
/// </summary>
64-
public SameSiteEnforcementMode CookieSameSite { get; set; }
64+
public SameSiteMode CookieSameSite { get; set; }
6565

6666
/// <summary>
6767
/// Determines if the browser should allow the cookie to be accessed by client-side javascript. The

src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ private void WriteNonceCookie(string nonce)
899899
new CookieOptions
900900
{
901901
HttpOnly = true,
902-
SameSite = Http.SameSiteEnforcementMode.Lax,
902+
SameSite = Http.SameSiteMode.Lax,
903903
Secure = Request.IsHttps,
904904
Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime)
905905
});
@@ -931,7 +931,7 @@ private string ReadNonceCookie(string nonce)
931931
var cookieOptions = new CookieOptions
932932
{
933933
HttpOnly = true,
934-
SameSite = Http.SameSiteEnforcementMode.Lax,
934+
SameSite = Http.SameSiteMode.Lax,
935935
Secure = Request.IsHttps
936936
};
937937

src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override async Task<AuthenticateResult> HandleRemoteAuthenticateAsync(
8383
var cookieOptions = new CookieOptions
8484
{
8585
HttpOnly = true,
86-
SameSite = SameSiteEnforcementMode.Lax,
86+
SameSite = SameSiteMode.Lax,
8787
Secure = Request.IsHttps
8888
};
8989

@@ -161,7 +161,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext context)
161161
var cookieOptions = new CookieOptions
162162
{
163163
HttpOnly = true,
164-
SameSite = SameSiteEnforcementMode.Lax,
164+
SameSite = SameSiteMode.Lax,
165165
Secure = Request.IsHttps,
166166
Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout),
167167
};

src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties
203203
var cookieOptions = new CookieOptions
204204
{
205205
HttpOnly = true,
206-
SameSite = SameSiteEnforcementMode.Lax,
206+
SameSite = SameSiteMode.Lax,
207207
Secure = Request.IsHttps,
208208
Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout),
209209
};
@@ -243,7 +243,7 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties
243243
var cookieOptions = new CookieOptions
244244
{
245245
HttpOnly = true,
246-
SameSite = SameSiteEnforcementMode.Lax,
246+
SameSite = SameSiteMode.Lax,
247247
Secure = Request.IsHttps
248248
};
249249
Response.Cookies.Delete(cookieName, cookieOptions);

src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ private void ApplyPolicy(CookieOptions options)
156156
case MinimumSameSiteStrictnessPolicy.None:
157157
break;
158158
case MinimumSameSiteStrictnessPolicy.Lax:
159-
if (options.SameSite == SameSiteEnforcementMode.None)
159+
if (options.SameSite == SameSiteMode.None)
160160
{
161-
options.SameSite = SameSiteEnforcementMode.Lax;
161+
options.SameSite = SameSiteMode.Lax;
162162
}
163163
break;
164164
case MinimumSameSiteStrictnessPolicy.Strict:
165-
options.SameSite = SameSiteEnforcementMode.Strict;
165+
options.SameSite = SameSiteMode.Strict;
166166
break;
167167
default:
168168
throw new InvalidOperationException($"Unrecognized {nameof(MinimumSameSiteStrictnessPolicy)} value {Policy.SameSite.ToString()}");

test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public async Task CookieOptionsAlterSetCookieHeader()
207207
o.CookiePath = "/foo";
208208
o.CookieDomain = "another.com";
209209
o.CookieSecure = CookieSecurePolicy.Always;
210-
o.CookieSameSite = SameSiteEnforcementMode.None;
210+
o.CookieSameSite = SameSiteMode.None;
211211
o.CookieHttpOnly = true;
212212
}, SignInAsAlice, baseAddress: new Uri("http://example.com/base"));
213213

@@ -226,7 +226,7 @@ public async Task CookieOptionsAlterSetCookieHeader()
226226
{
227227
o.CookieName = "SecondCookie";
228228
o.CookieSecure = CookieSecurePolicy.None;
229-
o.CookieSameSite = SameSiteEnforcementMode.Strict;
229+
o.CookieSameSite = SameSiteMode.Strict;
230230
o.CookieHttpOnly = false;
231231
}, SignInAsAlice, baseAddress: new Uri("http://example.com/base"));
232232

test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void AppendLargeCookieWithLimit_Chunked()
2727
HttpContext context = new DefaultHttpContext();
2828

2929
string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
30-
new ChunkingCookieManager() { ChunkSize = 30 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions());
30+
new ChunkingCookieManager() { ChunkSize = 44 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions());
3131
var values = context.Response.Headers["Set-Cookie"];
3232
Assert.Equal(9, values.Count);
3333
Assert.Equal<string[]>(new[]

test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public class CookiePolicyTests
3939
private RequestDelegate SameSiteCookieAppends = context =>
4040
{
4141
context.Response.Cookies.Append("A", "A");
42-
context.Response.Cookies.Append("B", "B", new CookieOptions { SameSite = Http.SameSiteEnforcementMode.None });
42+
context.Response.Cookies.Append("B", "B", new CookieOptions { SameSite = Http.SameSiteMode.None });
4343
context.Response.Cookies.Append("C", "C", new CookieOptions());
44-
context.Response.Cookies.Append("D", "D", new CookieOptions { SameSite = Http.SameSiteEnforcementMode.Lax });
45-
context.Response.Cookies.Append("E", "E", new CookieOptions { SameSite = Http.SameSiteEnforcementMode.Strict });
44+
context.Response.Cookies.Append("D", "D", new CookieOptions { SameSite = Http.SameSiteMode.Lax });
45+
context.Response.Cookies.Append("E", "E", new CookieOptions { SameSite = Http.SameSiteMode.Strict });
4646
return Task.FromResult(0);
4747
};
4848

0 commit comments

Comments
 (0)