forked from forgejo/forgejo
Support setting cookie domain (#6288)
Signed-off-by: Tamal Saha <tamal@appscode.com>
This commit is contained in:
parent
d95237b561
commit
2102f9d92d
15 changed files with 58 additions and 46 deletions
11
vendor/github.com/go-macaron/csrf/csrf.go
generated
vendored
11
vendor/github.com/go-macaron/csrf/csrf.go
generated
vendored
|
@ -25,7 +25,7 @@ import (
|
|||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
const _VERSION = "0.1.0"
|
||||
const _VERSION = "0.1.1"
|
||||
|
||||
func Version() string {
|
||||
return _VERSION
|
||||
|
@ -58,6 +58,8 @@ type csrf struct {
|
|||
Form string
|
||||
// Cookie name value for setting and getting csrf token.
|
||||
Cookie string
|
||||
//Cookie domain
|
||||
CookieDomain string
|
||||
//Cookie path
|
||||
CookiePath string
|
||||
// Cookie HttpOnly flag value used for the csrf token.
|
||||
|
@ -123,8 +125,10 @@ type Options struct {
|
|||
Form string
|
||||
// Cookie value used to set and get token.
|
||||
Cookie string
|
||||
// Cookie domain.
|
||||
CookieDomain string
|
||||
// Cookie path.
|
||||
CookiePath string
|
||||
CookiePath string
|
||||
CookieHttpOnly bool
|
||||
// Key used for getting the unique ID per user.
|
||||
SessionKey string
|
||||
|
@ -187,6 +191,7 @@ func Generate(options ...Options) macaron.Handler {
|
|||
Header: opt.Header,
|
||||
Form: opt.Form,
|
||||
Cookie: opt.Cookie,
|
||||
CookieDomain: opt.CookieDomain,
|
||||
CookiePath: opt.CookiePath,
|
||||
CookieHttpOnly: opt.CookieHttpOnly,
|
||||
ErrorFunc: opt.ErrorFunc,
|
||||
|
@ -222,7 +227,7 @@ func Generate(options ...Options) macaron.Handler {
|
|||
// FIXME: actionId.
|
||||
x.Token = GenerateToken(x.Secret, x.ID, "POST")
|
||||
if opt.SetCookie {
|
||||
ctx.SetCookie(opt.Cookie, x.Token, 0, opt.CookiePath, "", opt.Secure, opt.CookieHttpOnly, time.Now().AddDate(0, 0, 1))
|
||||
ctx.SetCookie(opt.Cookie, x.Token, 0, opt.CookiePath, opt.CookieDomain, opt.Secure, opt.CookieHttpOnly, time.Now().AddDate(0, 0, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue