Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeySize is returned when the symmetric key for the database is the incorrect size. ErrKeySize = errors.New("symmetric key for database is incorrect size") // ErrNotFound is returned when a record is not found. ErrNotFound = errors.New("not found") )
var ( // ErrPostgresSetupCheck is the error returned when the Postgres setup check fails. ErrPostgresSetupCheck = errors.New("failed to perform Postgres setup check") )
var ( // ErrSemVer indicates a semver is invalid. ErrSemVer = errors.New("invalid semver") )
Functions ¶
func DecodeAES256Base64 ¶ added in v0.5.1
DecodeAES256Base64 decodes a Base64 encoded AES256 key.
Types ¶
type Config ¶ added in v0.5.1
type Config struct { AES256KeyBase64 string `json:"aes256KeyBase64"` AutoMigrate bool `json:"autoMigrate"` DSN string `json:"dsn"` Health *jt.JSONType[time.Duration] `json:"health"` InitialTimeout *jt.JSONType[time.Duration] `json:"initialTimeout"` MaxIdle *jt.JSONType[time.Duration] `json:"maxIdle"` MinConns int32 `json:"minConns"` PlaintextClaims bool `json:"plaintextClaims"` PlaintextJWK bool `json:"plaintextJWK"` }
Config is the configuration for Postgres storage.
func (Config) DefaultsAndValidate ¶ added in v0.5.1
DefaultsAndValidate implements the jsontype.Config interface.
type Migrator ¶ added in v0.5.1
type Migrator interface { // Migrate applies all migrations in order. It will automatically skip migrations that have . Migrate(ctx context.Context) error }
Migrator is the interface for applying migrations.
Migrator only migrates in the forward direction. It does not support rolling back migrations. Ensure you have quick and robust database backup and restore procedure before running migrations.
No other program should interact with the database while the Migrator is running.
No Migrator implementation should depend on code elsewhere in this project.
func NewMigrator ¶ added in v0.5.1
func NewMigrator(pool *pgxpool.Pool, options MigratorOptions) (Migrator, error)
NewMigrator returns a new Migrator for a Postgres storage implementation.
type MigratorOptions ¶ added in v0.5.1
MigratorOptions are options for creating a Migrator.
type ReadSigningKeyOptions ¶
type ReadSigningKeyOptions struct {
JWTAlg string
}
ReadSigningKeyOptions are the options for the SigningKeyRead method.
type Setup ¶ added in v0.5.1
type Setup struct { PlaintextClaims bool `json:"plaintextClaims,omitempty"` PlaintextJWK bool `json:"plaintextJWK,omitempty"` SemVer string `json:"semver,omitempty"` // https://pkg.go.dev/golang.org/x/mod/semver }
Setup is the JSON data that sits in the setup table.
type Storage ¶
type Storage interface { Begin(ctx context.Context) (Tx, error) Close(ctx context.Context) error TestingTruncate(ctx context.Context) error SAAdminCreate(ctx context.Context, args model.ValidAdminCreateParams) error SACreate(ctx context.Context, args model.ValidServiceAccountCreateParams) (model.ServiceAccount, error) SARead(ctx context.Context, u uuid.UUID) (model.ServiceAccount, error) SAReadFromAPIKey(ctx context.Context, apiKey uuid.UUID) (model.ServiceAccount, error) SigningKeyRead(ctx context.Context, options ReadSigningKeyOptions) (jwk jwkset.JWK, err error) SigningKeyDefaultRead(ctx context.Context) (jwk jwkset.JWK, err error) SigningKeyDefaultUpdate(ctx context.Context, keyID string) error jwkset.Storage magiclink.Storage otp.Storage }
Storage is the interface for magiclinksdev storage.
type Transaction ¶ added in v0.5.1
type Transaction struct {
Tx pgx.Tx
}
Transaction is a storage.Tx implementation for Postgres.