cookies

package
v7.0.0-...-1c7ecba Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractStateSubstring

func ExtractStateSubstring(req *http.Request) string

ExtractStateSubstring extract the initial state characters, to add it to the CSRF cookie name

func GenerateCookieName

func GenerateCookieName(req *http.Request, opts *options.Cookie) string

GenerateCookieName in case cookie options state that CSRF cookie has fixed name then set fixed name, otherwise build name based on the state

func GetCookieDomain

func GetCookieDomain(req *http.Request, cookieDomains []string) string

GetCookieDomain returns the correct cookie domain given a list of domains by checking the X-Fowarded-Host and host header of an an http request

func MakeCookieFromOptions

func MakeCookieFromOptions(req *http.Request, name string, value string, opts *options.Cookie, expiration time.Duration, now time.Time) *http.Cookie

MakeCookieFromOptions constructs a cookie based on the given *options.CookieOptions, value and creation time

func ParseSameSite

func ParseSameSite(v string) http.SameSite

Parse a valid http.SameSite value from a user supplied string for use of making cookies.

Types

type CSRF

type CSRF interface {
	HashOAuthState() string
	HashOIDCNonce() string
	CheckOAuthState(string) bool
	CheckOIDCNonce(string) bool
	GetCodeVerifier() string

	SetSessionNonce(s *sessions.SessionState)

	SetCookie(http.ResponseWriter, *http.Request) (*http.Cookie, error)
	ClearCookie(http.ResponseWriter, *http.Request)
}

CSRF manages various nonces stored in the CSRF cookie during the initial authentication flows.

func LoadCSRFCookie

func LoadCSRFCookie(req *http.Request, opts *options.Cookie) (CSRF, error)

LoadCSRFCookie loads a CSRF object from a request's CSRF cookie

func NewCSRF

func NewCSRF(opts *options.Cookie, codeVerifier string) (CSRF, error)

NewCSRF creates a CSRF with random nonces

Jump to

Keyboard shortcuts

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