Documentation
¶
Overview ¶
Package file keeps sessions in files, in a directory, one for each, named by the SHA-256 of its token, which isn't kept, so they last when the server restarts, without a database.
Index ¶
- type Opt
- type Sessions
- func (s *Sessions) Consume(_ context.Context, id string, expires time.Time) error
- func (s *Sessions) Create(_ context.Context, session schema.Session) (*schema.SessionToken, error)
- func (s *Sessions) Key() ([]byte, error)
- func (s *Sessions) Revoke(_ context.Context, id string) error
- func (s *Sessions) Session(_ context.Context, token string) (*schema.Session, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sessions ¶
type Sessions struct {
// contains filtered or unexported fields
}
Sessions keeps sessions in files, in a directory, which only its owner can read
func New ¶
New returns sessions in the directory, which is made, when it isn't, and which only its owner can read or write, so no one else can read sessions, or add one, with a token they choose
func (*Sessions) Consume ¶
Consume consumes the ID, until it expires, as a file, named by its hash, which is created only when it isn't there, so it's consumed once, by any server which shares the directory, or after a restart. Those which have expired are removed.
func (*Sessions) Create ¶
Create keeps a new session, with a new token, whose hash is its ID and file name, and removes those which have expired
func (*Sessions) Key ¶
Key returns the key of the sessions, of 32 bytes, such as the one which seals sign-ins, and OAuth clients' IDs and codes, so they last when the server restarts, and servers which share the directory accept each other's. It's in the directory, which only its owner can read, out of reach of anything else, such as credentials, which could replace it. It's made when it isn't there, at once, so when servers make it at the same time, there's one, which they all return.