Documentation
¶
Index ¶
- Constants
- Variables
- func ClearAuthCookie(w http.ResponseWriter)
- func ClearCookie(w http.ResponseWriter, name string)
- func ClearOAuth2StateCookie(w http.ResponseWriter)
- func FromRequestContext[T any](r *http.Request, key any) (T, bool)
- func GetCookie(r *http.Request, name string) (string, error)
- func GetJWTFromCookie(r *http.Request) (string, error)
- func InputFromContext[T any](r *http.Request) (T, bool)
- func SetAuthCookie(w http.ResponseWriter, tokenString string, maxAge int)
- func SetCookie(w http.ResponseWriter, name, value string, maxAge int)
- func SetOAuth2StateCookie(w http.ResponseWriter, state string)
- func VerifyOAuth2State(r *http.Request, state string) error
- type State
Constants ¶
View Source
const ( // OAuth2StateCookieName is the name of the cookie storing OAuth2 state. OAuth2StateCookieName = "oauth2_state" // OAuth2StateExpiration is the expiration time for OAuth2 state cookie in seconds. OAuth2StateExpiration = 300 // 5 minutes )
View Source
const StateByteLength = 32
Variables ¶
View Source
var (
ErrCookieNotFound = errors.New("cookie not found")
)
View Source
var ErrInvalidStateInfo = errors.New("invalid state info")
Functions ¶
func ClearAuthCookie ¶
func ClearAuthCookie(w http.ResponseWriter)
ClearAuthCookie clears the authentication cookie.
func ClearCookie ¶
func ClearCookie(w http.ResponseWriter, name string)
ClearCookie clears a cookie by setting its MaxAge to -1.
func ClearOAuth2StateCookie ¶
func ClearOAuth2StateCookie(w http.ResponseWriter)
ClearOAuth2StateCookie clears the OAuth2 state cookie.
func GetJWTFromCookie ¶
GetJWTFromCookie extracts JWT token from the request cookie.
func SetAuthCookie ¶
func SetAuthCookie(w http.ResponseWriter, tokenString string, maxAge int)
SetAuthCookie sets the JWT token as a secure httpOnly cookie.
func SetCookie ¶
func SetCookie(w http.ResponseWriter, name, value string, maxAge int)
SetCookie sets a cookie with the given name, value, and max age.
func SetOAuth2StateCookie ¶
func SetOAuth2StateCookie(w http.ResponseWriter, state string)
SetOAuth2StateCookie stores the OAuth2 state parameter in a cookie for verification.
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func NewStateFromEncode ¶
Click to show internal directories.
Click to hide internal directories.