Documentation
¶
Overview ¶
Package postgresstore keeps gobrowserlogin's login attempts and sessions in PostgreSQL, through database/sql and whichever driver the application already uses.
The tables are Schema, which the application applies through its own migrations. New checks they are there, so a database missing them fails at startup rather than at the first login.
Index ¶
- Variables
- type Store
- func (s *Store) DeleteExpired(ctx context.Context, now time.Time) error
- func (s *Store) DeleteSession(ctx context.Context, key gobrowserlogin.Key) error
- func (s *Store) LoadSession(ctx context.Context, key gobrowserlogin.Key) (gobrowserlogin.Session, error)
- func (s *Store) SaveLoginAttempt(ctx context.Context, key gobrowserlogin.Key, ...) error
- func (s *Store) SaveSession(ctx context.Context, key gobrowserlogin.Key, session gobrowserlogin.Session) error
- func (s *Store) TakeLoginAttempt(ctx context.Context, key gobrowserlogin.Key) (gobrowserlogin.LoginAttempt, error)
- func (s *Store) TouchSession(ctx context.Context, key gobrowserlogin.Key, seenAt, expiresAt time.Time) error
Constants ¶
This section is empty.
Variables ¶
var Schema string
Schema creates the two tables a Store reads and writes.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a gobrowserlogin.Store in PostgreSQL.
func New ¶
New returns a Store over db, after checking that Schema's tables and columns are there. db reaches PostgreSQL through any database/sql driver: pgx's stdlib.OpenDBFromPool shares an application's pgxpool.
func (*Store) DeleteExpired ¶
DeleteExpired implements gobrowserlogin.Store.
func (*Store) DeleteSession ¶
DeleteSession implements gobrowserlogin.Store.
func (*Store) LoadSession ¶
func (s *Store) LoadSession(ctx context.Context, key gobrowserlogin.Key) (gobrowserlogin.Session, error)
LoadSession implements gobrowserlogin.Store.
func (*Store) SaveLoginAttempt ¶
func (s *Store) SaveLoginAttempt(ctx context.Context, key gobrowserlogin.Key, attempt gobrowserlogin.LoginAttempt) error
SaveLoginAttempt implements gobrowserlogin.Store.
func (*Store) SaveSession ¶
func (s *Store) SaveSession(ctx context.Context, key gobrowserlogin.Key, session gobrowserlogin.Session) error
SaveSession implements gobrowserlogin.Store.
func (*Store) TakeLoginAttempt ¶
func (s *Store) TakeLoginAttempt(ctx context.Context, key gobrowserlogin.Key) (gobrowserlogin.LoginAttempt, error)
TakeLoginAttempt implements gobrowserlogin.Store. The row is deleted by the statement that returns it, so two callbacks racing on one attempt cannot both read it.
func (*Store) TouchSession ¶
func (s *Store) TouchSession(ctx context.Context, key gobrowserlogin.Key, seenAt, expiresAt time.Time) error
TouchSession implements gobrowserlogin.Store.