Documentation
¶
Overview ¶
Package login layers login sessions over the auth package: a Manager authenticates credentials, mints a random token per login, and expires sessions after an idle timeout. The clock is injectable so timeout behavior is testable without sleeping. The package depends only on the standard library and auth.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// Now returns the current time; it defaults to time.Now and may be
// replaced (typically in tests) to drive timeout behavior deterministically.
Now func() time.Time
// contains filtered or unexported fields
}
Manager issues and tracks sessions backed by an auth.Store. It is safe for concurrent use.
func NewManager ¶
NewManager returns a Manager that authenticates against store and expires sessions idle for longer than timeout.
func (*Manager) Current ¶
Current returns the user behind a live token, refreshing the session. It returns false when the token is unknown or expired.
func (*Manager) Login ¶
Login authenticates name/password against the store and, on success, mints a new session with a random token. It returns an error on bad credentials.