session

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = fmt.Errorf("session not found")

Functions

func MakeCookie

func MakeCookie(req *http.Request, name string, value string, secure bool, expiration time.Duration) *http.Cookie

Types

type InMemoryStore added in v0.7.0

type InMemoryStore struct {
	// contains filtered or unexported fields
}

func NewInMemoryStore added in v0.7.0

func NewInMemoryStore() *InMemoryStore

func (*InMemoryStore) Delete added in v0.7.0

func (s *InMemoryStore) Delete(sessionID string) error

func (*InMemoryStore) Load added in v0.7.0

func (s *InMemoryStore) Load(sessionID string) (*State, error)

func (*InMemoryStore) Save added in v0.7.0

func (s *InMemoryStore) Save(state *State) error

type State

type State struct {
	Token       TokenInfo `msgpack:"tok,omitempty"`
	SessionID   string    `msgpack:"sid,omitempty"`
	ClusterID   string    `msgpack:"cid,omitempty"`
	RedirectURL string    `msgpack:"red,omitempty"`
	CreatedAt   time.Time `msgpack:"cat,omitempty"`
	ExpiresAt   time.Time `msgpack:"eat,omitempty"`
}

State is the data stored on the clientside as a browser cookie. To be independent of the OIDC token sizes, it only stores the absolute minimum information required for this particular backend implementation. Especially when lots of groups and claims are involved, the tokens can grow to a size larger than allowed by browsers for cookies, and even compression would only be a small adhesive strip, not a solution.

func (*State) Encode

func (s *State) Encode() ([]byte, error)

func (*State) IsExpired added in v0.7.0

func (s *State) IsExpired() bool

IsExpired checks if the session has expired

func (*State) SetExpiration added in v0.7.0

func (s *State) SetExpiration(duration time.Duration)

SetExpiration sets the session expiration time

type Store added in v0.7.0

type Store interface {
	Save(state *State) error
	Load(sessionID string) (*State, error)
	Delete(sessionID string) error
}

type TokenInfo

type TokenInfo struct {
	Subject string   `msgpack:"sub,omitempty"`
	Issuer  string   `msgpack:"iss,omitempty"`
	Groups  []string `msgpack:"grp,omitempty"`
}

Jump to

Keyboard shortcuts

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