gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

session_options_go1.11.go (1025B)


      1 // +build go1.11
      2 
      3 package sessions
      4 
      5 import (
      6 	gsessions "github.com/gorilla/sessions"
      7 	"net/http"
      8 )
      9 
     10 // Options stores configuration for a session or session store.
     11 // Fields are a subset of http.Cookie fields.
     12 type Options struct {
     13 	Path   string
     14 	Domain string
     15 	// MaxAge=0 means no 'Max-Age' attribute specified.
     16 	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
     17 	// MaxAge>0 means Max-Age attribute present and given in seconds.
     18 	MaxAge   int
     19 	Secure   bool
     20 	HttpOnly bool
     21 	// rfc-draft to preventing CSRF: https://tools.ietf.org/html/draft-west-first-party-cookies-07
     22 	//   refer: https://godoc.org/net/http
     23 	//          https://www.sjoerdlangkemper.nl/2016/04/14/preventing-csrf-with-samesite-cookie-attribute/
     24 	SameSite http.SameSite
     25 }
     26 
     27 func (options Options) ToGorillaOptions() *gsessions.Options {
     28 	return &gsessions.Options{
     29 		Path:     options.Path,
     30 		Domain:   options.Domain,
     31 		MaxAge:   options.MaxAge,
     32 		Secure:   options.Secure,
     33 		HttpOnly: options.HttpOnly,
     34 		SameSite: options.SameSite,
     35 	}
     36 }