emailverification

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 10 Imported by: 0

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

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

func ParseToken

func ParseToken[M any](raw secret.String) (Token[M], error)

type Verification

type Verification[M model.Identifiable, K any] struct {
	// contains filtered or unexported fields
}

func New

func New[M model.Identifiable, K any](store *challenge.Store, provider auth.Provider[M, K], binding Model[M, K], lifetime time.Duration) (*Verification[M, K], error)

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]) Prune

func (v *Verification[M, K]) Prune(ctx context.Context, limit int) (uint64, error)

func (*Verification[M, K]) Revoke

func (v *Verification[M, K]) Revoke(ctx context.Context, reference model.Reference[M, K]) (bool, error)

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.

Jump to

Keyboard shortcuts

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