session

package
v0.0.0-...-d1ad28d Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JadeOptions

type JadeOptions struct {
	CookiePrefix   string
	CookieDuration time.Duration

	Store         sessions.Store
	StateDuration time.Duration
	JWTSecret     string
	// contains filtered or unexported fields
}

func WithCookieDuration

func WithCookieDuration(duration time.Duration) JadeOptions

func WithCookiePrefix

func WithCookiePrefix(CookiePrefix string) JadeOptions

func WithJWTSecret

func WithJWTSecret(secret string) JadeOptions

WithJWTSecret sets the secret used for signing the JSON web token (JWT) that is used to store the authorization state.

The secret is used to sign the JWT and to verify the JWT when it is received. The secret should be a secure random string and should be kept private.

func WithKeyPairs

func WithKeyPairs(keypairs ...[]byte) JadeOptions

WithKeyPairs sets the secure cookie key pairs used to encode and decode the session cookie. The key pairs are used to rotate the session cookie keys and to ensure that the session cookie is secure.

func WithStateDuration

func WithStateDuration(duration time.Duration) JadeOptions

WithStateDuration sets the duration for the state cookie used for OAuth2 authorization flow. The state cookie is used to store the state of the authorization flow and is removed when the authorization flow is complete.

The default duration is 5 minutes.

func WithStore

func WithStore(store sessions.Store) JadeOptions

WithStore sets the session store used by the JadeStore.

The store is used for storing authentication state and session data.

type JadeStore

type JadeStore interface {
	BeginAuth(r *http.Request, w http.ResponseWriter, provider, redirect string) error
	CompleteAuth(r *http.Request, w http.ResponseWriter) error
	GetUserData(r *http.Request, w http.ResponseWriter) (*jade.User, error)
	GetAccessToken(r *http.Request) (string, error)
	DeleteSession(r *http.Request, w http.ResponseWriter, redirect string) error
}

func NewJadeStore

func NewJadeStore(options ...JadeOptions) JadeStore

Jump to

Keyboard shortcuts

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