oauthgocookie

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HMACSessionCookieManager

type HMACSessionCookieManager struct {
	// Name is the name of the cookie
	Name string
	// Secret is the secret used to sign the cookie data
	Secret []byte
	// TTL is the time-to-live of the cookie
	TTL time.Duration
	// Secure indicates whether the cookie should be secure
	Secure bool
	// Domain is the domain of the cookie
	Domain string
	// HttpOnly indicates whether the cookie should be HTTP-only
	HttpOnly bool
	// CookiePath is the path of the cookie
	CookiePath string
	// SameSite indicates whether the cookie should be same-site
	SameSite http.SameSite
}

HMACSessionCookieManager is a session cookie manager that uses HMAC to sign the cookie data.

func (*HMACSessionCookieManager) Clear

Clear clears a session cookie.

func (*HMACSessionCookieManager) Expiry

func (*HMACSessionCookieManager) Parse

Parse parses a session cookie.

func (*HMACSessionCookieManager) Set

Set sets a session in a cookie.

type SessionCookieManager

type SessionCookieManager interface {
	Set(w http.ResponseWriter, s SessionCookiePayload) error
	Clear(w http.ResponseWriter)
	Parse(r *http.Request) (*SessionCookiePayload, bool)
	Expiry() time.Duration
}

SessionCookieManager is an interface for managing session cookies.

func GetDefaultHMACCookieSessionManager

func GetDefaultHMACCookieSessionManager() SessionCookieManager

GetDefaultHMACCookieSessionManager returns the default HMACSessionCookieManager. You can override the default values by passing in a custom CookieSessionManager.

type SessionCookiePayload

type SessionCookiePayload struct {
	// Provider is the name of the OAuth provider e.g. "google"
	Provider string `json:"provider"`
	// Subject is the user's unique identifier
	Subject string `json:"sub"`
	// Email is the user's email address
	Email string `json:"email"`
	// Name is the user's full name
	Name string `json:"name"`
	// Expiry is the time when the session expires
	Expiry time.Time `json:"exp"`
}

SessionCookiePayload is the payload of the session cookie.

Jump to

Keyboard shortcuts

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