From 4fa797feaa1e1664ebcd50280f55f8100e0214ea Mon Sep 17 00:00:00 2001 From: xjl662750 <42456559+xjl662750@users.noreply.github.com> Date: Tue, 29 Jun 2021 09:31:50 +0800 Subject: [PATCH] Update output.go add SameSite for Cookie --- server/web/context/output.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/web/context/output.go b/server/web/context/output.go index a981acfe..eeac368e 100644 --- a/server/web/context/output.go +++ b/server/web/context/output.go @@ -154,6 +154,13 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface fmt.Fprintf(&b, "; HttpOnly") } } + + // default empty + if len(others) > 5 { + if v, ok := others[5].(string); ok && len(v) > 0 { + fmt.Fprintf(&b, "; SameSite=%s", sanitizeValue(v)) + } + } output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String()) }