Documentation
¶
Index ¶
- type CookieEncoder
- type CookieEncryptor
- type CookieOptions
- type CookieSessionManager
- type JSONCookieEncoder
- type SecureCookieManager
- func (cm *SecureCookieManager) Delete(w http.ResponseWriter, name string, opts *CookieOptions) (*http.Cookie, error)
- func (cm *SecureCookieManager) Get(req *http.Request, name string, v interface{}) (*http.Cookie, error)
- func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *CookieOptions, v interface{}) (*http.Cookie, error)
- type Session
- type SessionConstructor
- type SessionManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CookieEncoder ¶
type CookieEncoder interface {
Encode(v interface{}, c *http.Cookie) error
Decode(v interface{}, c *http.Cookie) error
}
CookieEncoder encodes/decodes a specific data structure into a cookie's content.
type CookieEncryptor ¶
type CookieEncryptor struct {
// contains filtered or unexported fields
}
CookieEncryptor implements cookie encryption and signing to allow securely storing sensitive information on the user-agent.
func NewCookieEncryptor ¶
func NewCookieEncryptor(secret string, iterations int) *CookieEncryptor
NewCookieEncryptor creates a new instance of CookieEncryptor. Creating this instance is expensive since it has to derives the keys.
type CookieOptions ¶
type CookieSessionManager ¶
type CookieSessionManager struct {
// contains filtered or unexported fields
}
CookieSessionManager manages session by storing the session data directly into a secure cookie.
func NewCookieSessionManager ¶
func NewCookieSessionManager(cm *SecureCookieManager, name string, opts *CookieOptions) *CookieSessionManager
NewCookieSessionManager creates a new cookie-based session manager.
func (*CookieSessionManager) Current ¶
func (sm *CookieSessionManager) Current(req *http.Request, sess Session) error
Current fetches the current session from the request cookie, starting one if it doesn't exist.
func (*CookieSessionManager) Update ¶
func (sm *CookieSessionManager) Update(w http.ResponseWriter, req *http.Request, sess Session) error
Update updates the session with the given struct, replacing the existing session data with it.
type JSONCookieEncoder ¶
type JSONCookieEncoder struct{}
JSONCookieEncoder encodes/decodes cookies using encoding/json
type SecureCookieManager ¶
type SecureCookieManager struct {
Encryptor *CookieEncryptor
Encoder CookieEncoder
}
func (*SecureCookieManager) Delete ¶
func (cm *SecureCookieManager) Delete(w http.ResponseWriter, name string, opts *CookieOptions) (*http.Cookie, error)
Deletes the Cookie, setting value to empty and expiring in the past.
func (*SecureCookieManager) Get ¶
func (cm *SecureCookieManager) Get(req *http.Request, name string, v interface{}) (*http.Cookie, error)
Get gets the Cookie, decrypted it and deserialized it into v. Returns the decrypted cookie.
func (*SecureCookieManager) Set ¶
func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *CookieOptions, v interface{}) (*http.Cookie, error)
Set a cookie with the data set to the encrypted version of the serialization of v. Returns the http.Cookie generated.