-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ghttp: add cookie security configurations #1549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1549 +/- ##
==========================================
- Coverage 71.05% 69.79% -1.26%
==========================================
Files 444 438 -6
Lines 42322 42447 +125
==========================================
- Hits 30070 29625 -445
- Misses 10357 10927 +570
Partials 1895 1895
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
net/ghttp/ghttp_server_cookie.go
Outdated
| // The optional parameter `httpOnly` specifies if the cookie item is only available in HTTP, | ||
| // which is usually empty. | ||
| func (c *Cookie) SetCookie(key, value, domain, path string, maxAge time.Duration, httpOnly ...bool) { | ||
| func (c *Cookie) SetCookie(key, value, domain, path string, maxAge time.Duration, extra ...map[string]interface{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FlyingBlazer 感谢参与贡献!我这里建议使用struct结构化定义Cookie的额外参数,而不是通过非结构化的map。因此建议您可以定义一个CookieOption的结构体,将需要额外定义的参数使用结构化管理起来。
net/ghttp/ghttp_server_cookie.go
Outdated
|
|
||
| // CookieOptions provides security config for cookies | ||
| type CookieOptions struct { | ||
| sameSite http.SameSite // cookie SameSite property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
属性需要设置公开,否则使用者无法传递设置对应的Cookie选项。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
抱歉一直没抽出来时间,已经改了
Add configurations for cookie security properties:
Pending Unit Test
Some questions:
Cookie.SetCookie'shttpOnlyparameter?