You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2018/10/03 20:44:40 UTC
[06/10] mochiweb commit: updated refs/heads/upstream to 9608d78
Add support for SameSite cookie setting (#203)
Ref: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/c06e08ee
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/c06e08ee
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/c06e08ee
Branch: refs/heads/upstream
Commit: c06e08ee29e215cc7f3e5f940fabf5f5834a7096
Parents: b095122
Author: Robert Newson <rn...@apache.org>
Authored: Sat Sep 22 16:00:46 2018 +0100
Committer: Bob Ippolito <bo...@redivi.com>
Committed: Sat Sep 22 11:00:46 2018 -0400
----------------------------------------------------------------------
src/mochiweb_cookies.erl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/c06e08ee/src/mochiweb_cookies.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_cookies.erl b/src/mochiweb_cookies.erl
index 9539041..013dbe0 100644
--- a/src/mochiweb_cookies.erl
+++ b/src/mochiweb_cookies.erl
@@ -52,6 +52,7 @@ cookie(Key, Value) ->
%% where Option = {max_age, int_seconds()} | {local_time, {date(), time()}}
%% | {domain, string()} | {path, string()}
%% | {secure, true | false} | {http_only, true | false}
+%% | {same_site, lax | strict}
%%
%% @doc Generate a Set-Cookie header field tuple.
cookie(Key, Value, Options) ->
@@ -109,7 +110,17 @@ cookie(Key, Value, Options) ->
_ ->
""
end,
- CookieParts = [Cookie, ExpiresPart, SecurePart, DomainPart, PathPart, HttpOnlyPart],
+ SameSitePart =
+ case proplists:get_value(same_site, Options) of
+ undefined ->
+ "";
+ lax ->
+ "; SameSite=Lax";
+ strict ->
+ "; SameSite=Strict"
+ end,
+ CookieParts = [Cookie, ExpiresPart, SecurePart, DomainPart, PathPart,
+ HttpOnlyPart, SameSitePart],
{"Set-Cookie", lists:flatten(CookieParts)}.