Documentation
¶
Overview ¶
Package sessionext tells the web app when the current browser session will end and lets the person extend it, so the app can warn before an idle timeout instead of losing unsaved work.
A session ends at the earlier of its idle deadline (last activity plus the instance's idle timeout) and its absolute lifetime. Extending restarts the idle clock; the lifetime never moves, so an instance's policy can't be bypassed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q store.Querier
Audit *audit.Logger
// Policy returns the instance authentication policy (the idle timeout).
Policy func(context.Context) (api.Policy, error)
Now func() time.Time
}
Service reads and extends the caller's session.
type SessionTiming ¶
type SessionTiming struct {
SignedInAt time.Time `json:"signedInAt" doc:"When this session was created"`
LastSeenAt time.Time `json:"lastSeenAt" doc:"Last activity the server recorded; the idle clock runs from here"`
// IdleTimeoutSeconds is 0 when the instance has no idle timeout.
IdleTimeoutSeconds int64 `json:"idleTimeoutSeconds" doc:"The instance's idle timeout, in seconds"`
IdleExpiresAt *time.Time `json:"idleExpiresAt,omitempty" doc:"When the session ends without further activity"`
ExpiresAt time.Time `json:"expiresAt" doc:"The session's absolute lifetime; extending never moves it"`
EndsAt time.Time `json:"endsAt" doc:"The earlier of idleExpiresAt and expiresAt"`
EndsBy string `json:"endsBy" enum:"idle,lifetime" doc:"Which limit ends the session first"`
Extendable bool `json:"extendable" doc:"Whether extending now would end the session later"`
ExtendsTo *time.Time `json:"extendsTo,omitempty" doc:"When the session would end after extending now"`
ServerTime time.Time `json:"serverTime" doc:"The server's clock, to correct for skew in the browser"`
}
SessionTiming says when the caller's session ends and what extending does.
Click to show internal directories.
Click to hide internal directories.