cookie

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cookie implements all cookie handling for the session package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieClient

type CookieClient struct {
	CookieName string
	Domain     string
	// contains filtered or unexported fields
}

CookieClient implements all cookie management for session package

func NewCookieClient

func NewCookieClient(secureCookie *securecookie.SecureCookie) *CookieClient

NewCookieClient returns a new CookieClient

func (*CookieClient) HasValidXSRFToken

func (c *CookieClient) HasValidXSRFToken(r *http.Request) bool

HasValidXSRFToken checks if the XSRF token is valid

func (*CookieClient) NewAuthCookie

func (c *CookieClient) NewAuthCookie(w http.ResponseWriter, sameSiteStrict bool, sessionID ccc.UUID) (map[types.SCKey]string, error)

NewAuthCookie writes a new Auth Cookie for given sessionID

func (*CookieClient) ReadAuthCookie

func (c *CookieClient) ReadAuthCookie(r *http.Request) (map[types.SCKey]string, bool)

ReadAuthCookie reads the Auth cookie from the request

func (*CookieClient) ReadXSRFCookie

func (c *CookieClient) ReadXSRFCookie(r *http.Request) (map[types.STKey]string, bool)

ReadXSRFCookie reads the XSRF cookie from the request

func (*CookieClient) ReadXSRFHeader

func (c *CookieClient) ReadXSRFHeader(r *http.Request) (map[types.STKey]string, bool)

ReadXSRFHeader reads the XSRF header from the request

func (*CookieClient) SetXSRFTokenCookie

func (c *CookieClient) SetXSRFTokenCookie(w http.ResponseWriter, r *http.Request, sessionID ccc.UUID, cookieExpiration time.Duration) (set bool)

SetXSRFTokenCookie sets the cookie if it does not exist and updates the cookie when it is close to expiration.

func (*CookieClient) WriteAuthCookie

func (c *CookieClient) WriteAuthCookie(w http.ResponseWriter, sameSiteStrict bool, cval map[types.SCKey]string) error

WriteAuthCookie writes the Auth cookie to the response

func (*CookieClient) WriteXSRFCookie

func (c *CookieClient) WriteXSRFCookie(w http.ResponseWriter, cookieExpiration time.Duration, cval map[types.STKey]string) error

WriteXSRFCookie writes the XSRF cookie to the response

type CookieHandler

type CookieHandler interface {
	NewAuthCookie(w http.ResponseWriter, sameSiteStrict bool, sessionID ccc.UUID) (map[types.SCKey]string, error)
	ReadAuthCookie(r *http.Request) (map[types.SCKey]string, bool)
	WriteAuthCookie(w http.ResponseWriter, sameSiteStrict bool, cval map[types.SCKey]string) error
	SetXSRFTokenCookie(w http.ResponseWriter, r *http.Request, sessionID ccc.UUID, cookieExpiration time.Duration) (set bool)
	HasValidXSRFToken(r *http.Request) bool
}

CookieHandler Interface included for testability

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL