Documentation
¶
Overview ¶
Package emailverification binds one-time verification to a concrete model's current stored email. Verifying an email never issues an authentication proof.
Index ¶
- Constants
- type Issued
- type Model
- type Token
- type Verification
- func (v *Verification[M, K]) Complete(ctx context.Context, token Token[M]) (M, error)
- func (v *Verification[M, K]) Issue(ctx context.Context, reference model.Reference[M, K]) (Issued[M], error)
- func (v *Verification[M, K]) Prune(ctx context.Context, limit int) (uint64, error)
- func (v *Verification[M, K]) Revoke(ctx context.Context, reference model.Reference[M, K]) (bool, error)
- func (v *Verification[M, K]) Validate() error
- func (v *Verification[M, K]) WithObserver(observer auth.Observer) (*Verification[M, K], error)
Constants ¶
const DefaultLifetime = 24 * time.Hour
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model[M model.Identifiable, K any] struct { Lock func(context.Context, *database.Tx, K) (value.Optional[M], error) Email func(M) string EmailRevision func(M) challenge.Revision[M] Verified func(M) bool MarkVerified func(context.Context, *database.Tx, M) (M, error) Eligible func(context.Context, M) (bool, error) }
Model maps stored email state. EmailRevision must be persisted and replaced transactionally whenever Email changes; restoring an old address must never restore its old revision. MarkVerified must preserve email and revision. Eligible optionally replaces the provider's eligibility for this flow, for example when the provider only admits accounts with verified addresses.
type Verification ¶
type Verification[M model.Identifiable, K any] struct { // contains filtered or unexported fields }
func (*Verification[M, K]) Complete ¶
func (v *Verification[M, K]) Complete(ctx context.Context, token Token[M]) (M, error)
func (*Verification[M, K]) Issue ¶
func (v *Verification[M, K]) Issue(ctx context.Context, reference model.Reference[M, K]) (Issued[M], error)
Issue uses the model's currently locked email for binding. Applications deliver only to the issued Subject's stored email and use a uniform public response.
func (*Verification[M, K]) Validate ¶
func (v *Verification[M, K]) Validate() error
func (*Verification[M, K]) WithObserver ¶
func (v *Verification[M, K]) WithObserver(observer auth.Observer) (*Verification[M, K], error)
WithObserver reports EventVerified after each committed verification.