Documentation
¶
Overview ¶
Package postgres persists single-use recovery credentials through explicit migrations and generated queries. It borrows the application's existing pool.
Index ¶
- Constants
- func Migrations() []migrate.Definition
- type Backend
- func (b *Backend) Consume(ctx context.Context, address challenge.Address, hash challenge.Digest, ...) (value.Optional[challenge.Record], error)
- func (b *Backend) Issue(ctx context.Context, address challenge.Address, identity model.Identity, ...) (challenge.Record, error)
- func (b *Backend) Prune(ctx context.Context, address challenge.Address, limit int) (uint64, error)
- func (b *Backend) Revoke(ctx context.Context, address challenge.Address, identity model.Identity) (bool, error)
- type Config
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Migrations ¶
func Migrations() []migrate.Definition
Migrations must be registered and applied explicitly. Subject rows are stable synchronization records and are not garbage-collected by ordinary pruning.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend persists single-use challenges in PostgreSQL using a borrowed database pool.
func (*Backend) Consume ¶
func (b *Backend) Consume(ctx context.Context, address challenge.Address, hash challenge.Digest, apply func(context.Context, *database.Tx, challenge.Record) error) (value.Optional[challenge.Record], error)
Consume locks and rechecks the token, applies model changes and deletes the token in one transaction. Expiry during the action rolls back its writes.
func (*Backend) Issue ¶
func (b *Backend) Issue(ctx context.Context, address challenge.Address, identity model.Identity, hash challenge.Digest, lifetime time.Duration, prepare func(context.Context, *database.Tx) (challenge.Binding, error)) (challenge.Record, error)
Issue locks the challenge subject, prepares its binding and atomically replaces the previous token.
type Config ¶
Config's schema is shared by challenge and domain-model queries inside the callback. Instances must share synchronized clocks. Construction does no I/O.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the public schema and system clock.