Skip to content

Commit

Permalink
Rpc http cookie behavior on V3 (#5331)
Browse files Browse the repository at this point in the history
* change default to Unspecified

* by default, an unspecified SameSite value shouldn't be added

* use enum

* update test to be more accurate

* Add explicit reference to .NET core 3.1 for http features

* update reference
  • Loading branch information
mhoeger authored and fabiocav committed Apr 22, 2020
1 parent aec6339 commit 145d8cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/WebJobs.Script/WebJobs.Script.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.7.0" />
<PackageReference Include="Grpc.Core" Version="1.20.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.AppService.Proxy.Client" Version="2.0.10120001-f33e57bd" />
<PackageReference Include="Microsoft.Azure.Functions.JavaWorker" Version="1.5.2-SNAPSHOT" />
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="2.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ private static SameSiteMode RpcSameSiteEnumConverter(RpcHttpCookie.Types.SameSit
case RpcHttpCookie.Types.SameSite.Lax:
return SameSiteMode.Lax;
case RpcHttpCookie.Types.SameSite.None:
return SameSiteMode.None;
return SameSiteMode.Unspecified;
default:
return SameSiteMode.None;
return SameSiteMode.Unspecified;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ public async Task AddsHttpCookies()
{
new Tuple<string, string, CookieOptions>("firstCookie", "cookieValue", new CookieOptions()
{
SameSite = SameSiteMode.None
SameSite = SameSiteMode.Lax
}),
new Tuple<string, string, CookieOptions>("secondCookie", "cookieValue2", new CookieOptions()
{
Path = "/",
HttpOnly = true,
MaxAge = TimeSpan.FromSeconds(20)
MaxAge = TimeSpan.FromSeconds(20),
SameSite = SameSiteMode.Unspecified
})
}
};
Expand All @@ -78,7 +79,7 @@ public async Task AddsHttpCookies()
context.HttpContext.Response.Headers.TryGetValue("Set-Cookie", out StringValues cookies);

Assert.Equal(2, cookies.Count);
Assert.Equal("firstCookie=cookieValue; path=/; samesite=none", cookies[0]);
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]);
}
Expand Down

0 comments on commit 145d8cd

Please sign in to comment.