Skip to content

Commit

Permalink
Add ability to set samesite=none in out of proc http cookies (#5757)
Browse files Browse the repository at this point in the history
* add ability to set samesite=none in out of proc http cookies

* update test
  • Loading branch information
mhoeger authored and yojagad committed Apr 21, 2020
1 parent 9187de5 commit e7a5851
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,12 @@ message RpcException {

// Http cookie type. Note that only name and value are used for Http requests
message RpcHttpCookie {
// Enum that lets servers require that a cookie shouoldn't be sent with cross-site requests
// Enum that lets servers require that a cookie shouldn't be sent with cross-site requests
enum SameSite {
None = 0;
Lax = 1;
Strict = 2;
ExplicitNone = 3;
}

// Cookie name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ private static SameSiteMode RpcSameSiteEnumConverter(RpcHttpCookie.Types.SameSit
return SameSiteMode.Lax;
case RpcHttpCookie.Types.SameSite.None:
return SameSiteMode.Unspecified;
case RpcHttpCookie.Types.SameSite.ExplicitNone:
return SameSiteMode.None;
default:
return SameSiteMode.Unspecified;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public async Task AddsHttpCookies()
HttpOnly = true,
MaxAge = TimeSpan.FromSeconds(20),
SameSite = SameSiteMode.Unspecified
}),
new Tuple<string, string, CookieOptions>("thirdCookie", "cookieValue3", new CookieOptions()
{
SameSite = SameSiteMode.None
})
}
};
Expand All @@ -78,10 +82,10 @@ public async Task AddsHttpCookies()
await result.ExecuteResultAsync(context);
context.HttpContext.Response.Headers.TryGetValue("Set-Cookie", out StringValues cookies);

Assert.Equal(2, cookies.Count);
Assert.Equal(3, cookies.Count);
Assert.Equal("firstCookie=cookieValue; path=/; samesite=lax", cookies[0]);
// TODO: https://github.com/Azure/azure-functions-host/issues/4890
Assert.Equal("secondCookie=cookieValue2; max-age=20; path=/; httponly", cookies[1]);
Assert.Equal("thirdCookie=cookieValue3; path=/; samesite=none", cookies[2]);
}

[Fact]
Expand Down

0 comments on commit e7a5851

Please sign in to comment.