Documentation ¶
Overview ¶
Package sessions handles the storage, management, and validation of pomerium user sessions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSessionFound is the error for when no session is found. ErrNoSessionFound = errors.New("internal/sessions: session is not found") // ErrMalformed is the error for when a session is found but is malformed. ErrMalformed = errors.New("internal/sessions: session is malformed") // ErrNotValidYet indicates that token is used before time indicated in nbf claim. ErrNotValidYet = errors.New("internal/sessions: validation failed, token not valid yet (nbf)") // ErrExpired indicates that token is used after expiry time indicated in exp claim. ErrExpired = errors.New("internal/sessions: validation failed, token is expired (exp)") // ErrExpiryRequired indicates that the token does not contain a valid expiry (exp) claim. ErrExpiryRequired = errors.New("internal/sessions: validation failed, token expiry (exp) is required") // ErrIssuedInTheFuture indicates that the iat field is in the future. ErrIssuedInTheFuture = errors.New("internal/sessions: validation field, token issued in the future (iat)") // ErrInvalidAudience indicated invalid aud claim. ErrInvalidAudience = errors.New("internal/sessions: validation failed, invalid audience claim (aud)") )
var ( SessionCtxKey = &contextKey{"Session"} ErrorCtxKey = &contextKey{"Error"} )
Context keys
var ErrMissingID = errors.New("invalid session: missing id")
ErrMissingID is the error for a session state that has no ID set.
Functions ¶
func FromContext ¶ added in v0.4.0
FromContext retrieves context values for the user session state and error.
func NewContext ¶ added in v0.4.0
NewContext sets context values for the user session state and error.
func RetrieveSession ¶ added in v0.4.0
func RetrieveSession(s ...SessionLoader) func(http.Handler) http.Handler
RetrieveSession takes a slice of session loaders and tries to find a valid session in the order they were supplied and is added to the request's context
Types ¶
type SessionLoader ¶ added in v0.4.0
SessionLoader defines an interface for loading a session.
type SessionStore ¶
type SessionStore interface { SessionLoader ClearSession(http.ResponseWriter, *http.Request) SaveSession(http.ResponseWriter, *http.Request, interface{}) error }
SessionStore defines an interface for loading, saving, and clearing a session.
type State ¶ added in v0.4.0
type State struct { // Public claim values (as specified in RFC 7519). Issuer string `json:"iss,omitempty"` Subject string `json:"sub,omitempty"` Audience jwt.Audience `json:"aud,omitempty"` Expiry *jwt.NumericDate `json:"exp,omitempty"` NotBefore *jwt.NumericDate `json:"nbf,omitempty"` IssuedAt *jwt.NumericDate `json:"iat,omitempty"` ID string `json:"jti,omitempty"` // "ver" field is not standard, but is supported by most providers. Version Version `json:"ver,omitempty"` // Azure returns OID which should be used instead of subject. OID string `json:"oid,omitempty"` // Programmatic whether this state is used for machine-to-machine // programmatic access. Programmatic bool `json:"programmatic"` // DatabrokerServerVersion tracks the last referenced databroker server version // for the saved session. DatabrokerServerVersion uint64 `json:"databroker_server_version,omitempty"` // DatabrokerRecordVersion tracks the last referenced databroker record version // for the saved session. DatabrokerRecordVersion uint64 `json:"databroker_record_version,omitempty"` }
State is our object that keeps track of a user's session state
func NewSession ¶ added in v0.9.0
NewSession updates issuer, audience, and issuance timestamps but keeps parent expiry.
func (*State) UnmarshalJSON ¶ added in v0.6.3
UnmarshalJSON returns a State struct from JSON. Additionally munges a user's session by using by setting `user` claim to `sub` if empty.
type Version ¶ added in v0.10.0
type Version string
Version represents "ver" field in JWT public claims.
The field is not specified by RFC 7519, so providers can return either string or number (like okta).
func (*Version) UnmarshalJSON ¶ added in v0.10.0
UnmarshalJSON implements json.Unmarshaler interface.
Directories ¶
Path | Synopsis |
---|---|
Package cookie provides a cookie based implementation of session store and loader.
|
Package cookie provides a cookie based implementation of session store and loader. |
Package header provides a request header based implementation of a session loader.
|
Package header provides a request header based implementation of a session loader. |
Package mock provides a mock implementation of session store and loader.
|
Package mock provides a mock implementation of session store and loader. |
Package queryparam provides a query param based implementation of a both as session store and loader.
|
Package queryparam provides a query param based implementation of a both as session store and loader. |