postgresstore

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func New(ctx context.Context, db *sql.DB) (*Store, error)

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

func (s *Store) DeleteExpired(ctx context.Context, now time.Time) error

DeleteExpired implements gobrowserlogin.Store.

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, key gobrowserlogin.Key) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL