Documentation
¶
Index ¶
- func NewRandomEncryptedCookieSalt() (string, error)
- func NewRandomEncryptedCookieSecret() (string, error)
- func NewRandomEncryptedCookieURI(name string) (string, error)
- func RegisterCookie(ctx context.Context, scheme string, f CookieInitializeFunc) error
- func Schemes() []string
- type Config
- type Cookie
- type CookieInitializeFunc
- type EncryptedCookie
- func (c *EncryptedCookie) Delete(rsp http.ResponseWriter) error
- func (c *EncryptedCookie) Get(req *http.Request) (*memguard.LockedBuffer, error)
- func (c *EncryptedCookie) GetString(req *http.Request) (string, error)
- func (c *EncryptedCookie) Set(rsp http.ResponseWriter, buf *memguard.LockedBuffer) error
- func (c *EncryptedCookie) SetString(rsp http.ResponseWriter, value string) error
- func (c *EncryptedCookie) SetStringWithCookie(rsp http.ResponseWriter, value string, http_cookie *http.Cookie) error
- func (c *EncryptedCookie) SetWithCookie(rsp http.ResponseWriter, buf *memguard.LockedBuffer, http_cookie *http.Cookie) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRandomEncryptedCookieSalt ¶
NewRandomEncryptedCookieSalt returns a random salt value suitable for `encrypted://` cookie URIs.
func NewRandomEncryptedCookieSecret ¶
NewRandomEncryptedCookieSecret returns a random salt value suitable for `encrypted://` cookie URIs.
func NewRandomEncryptedCookieURI ¶
NewRandomEncryptedCookieURI() returns a new URI for creating an `EncryptedCookie` instance for 'name' with random values for the required secret and salt.
func RegisterCookie ¶
func RegisterCookie(ctx context.Context, scheme string, f CookieInitializeFunc) error
RegisterCookie() associates 'scheme' with 'f' in an internal list of avilable `Cookie` implementations.
Types ¶
type Config ¶
type Cookie ¶
type Cookie interface { // Get() returns the value of a HTTP cookie as a `awnumar/memguard.LockedBuffer` instance. Get(*http.Request) (*memguard.LockedBuffer, error) // GetString() returns the value of a HTTP cookie as a string. GetString(*http.Request) (string, error) // Get() assigned the value of a HTTP cookie from a `awnumar/memguard.LockedBuffer` instance. Set(http.ResponseWriter, *memguard.LockedBuffer) error // Get() assigned the value of a HTTP cookie from a string. SetString(http.ResponseWriter, string) error // SetWithCookie() assigned the value of a specific HTTP cookie from a `awnumar/memguard.LockedBuffer` instance. SetWithCookie(http.ResponseWriter, *memguard.LockedBuffer, *http.Cookie) error // SetStringWithCookie() assigned the value of a specific HTTP cookie from a string. SetStringWithCookie(http.ResponseWriter, string, *http.Cookie) error // Delete() removes the cookie from an HTTP response. Delete(http.ResponseWriter) error }
Cookie is an interface for working with HTTP cookies.
func NewCookie ¶
NewCookie() returns a new instance of `Cookie` for the scheme associated with 'uri'. It is assumed that this scheme will have previously been "registered" with the `RegisterCookie` method.
func NewEncryptedCookie ¶
NewEncryptedCookie() returns a new `EncryptedCookie` instance derived from 'uri' which is expected to take the form of:
encrypted://?name={NAME}&secret={SECRET}&salt={SECRET}
Where `{NAME}` is the name of the cookie for all subsequent operations; `{SECRET}` is the secret key used to encrypt the value of the cookie; `{SALT}` is the salt used to encrypt the cookie.
type CookieInitializeFunc ¶
CookieInitializeFunc is a function used to initialize an implementation of the `Cookie` interface.
type EncryptedCookie ¶
type EncryptedCookie struct { Cookie // contains filtered or unexported fields }
EncryptedCookie implements the `Cookie` interface for working with cookies whose values have been encrypted.
func (*EncryptedCookie) Delete ¶
func (c *EncryptedCookie) Delete(rsp http.ResponseWriter) error
Delete removes the cookie associated with 'c' from 'rsp'.
func (*EncryptedCookie) Get ¶
func (c *EncryptedCookie) Get(req *http.Request) (*memguard.LockedBuffer, error)
GetString returns the value of the cookie associated with 'c' in 'req' as an unencrypted `memguard.LockedBuffer` instance.
func (*EncryptedCookie) GetString ¶
func (c *EncryptedCookie) GetString(req *http.Request) (string, error)
GetString returns the value of the cookie associated with 'c' in 'req' as an unencrypted string.
func (*EncryptedCookie) Set ¶
func (c *EncryptedCookie) Set(rsp http.ResponseWriter, buf *memguard.LockedBuffer) error
Set assigns 'buf' as an encrypted string to a cookie associated with 'c' to 'rsp'.
func (*EncryptedCookie) SetString ¶
func (c *EncryptedCookie) SetString(rsp http.ResponseWriter, value string) error
SetString assigns 'value' as an encrypted string to a cookie associated with 'c' to 'rsp'.
func (*EncryptedCookie) SetStringWithCookie ¶
func (c *EncryptedCookie) SetStringWithCookie(rsp http.ResponseWriter, value string, http_cookie *http.Cookie) error
SetStringWithCookie assigns 'value' as an encrypted string to 'http_cookie' which is assigned to 'rsp'.
func (*EncryptedCookie) SetWithCookie ¶
func (c *EncryptedCookie) SetWithCookie(rsp http.ResponseWriter, buf *memguard.LockedBuffer, http_cookie *http.Cookie) error
SetWithCookie assigns 'buf' as an encrypted string to 'http_cookie' which is assigned to 'rsp'.