package model import ( verification "git.sendico.io/tech/sxchnge/product/verification/model" storable "git.sendico.io/tech/sxchnge/shared/database/record" "go.mongodb.org/mongo-driver/v2/bson" "time" ) type Channel string const Email Channel = "email" // Scope is supplied by the owning operation, never accepted as an authorization // decision from a caller's HTTP body. ContextRef identifies the exact operation. type Scope struct { Purpose verification.VerificationPurpose `bson:"purpose"` ContextRef string `bson:"contextRef"` } type Request struct { Subject bson.ObjectID Scope Scope Deadline time.Time IdempotencyKey string IP string } type Factor struct { ID string `bson:"id"` Channel Channel `bson:"channel"` Address string `bson:"address"` Verified bool `bson:"verified"` } type Profile struct { storable.Base `bson:",inline"` Preferred string `bson:"preferred"` Factors []Factor `bson:"factors"` Revision string `bson:"revision"` Fence string `bson:"fence"` } func (*Profile) Collection() string { return "two_factor_profiles" } type Record struct { storable.Base `bson:",inline"` Subject bson.ObjectID `bson:"subject"` Scope Scope `bson:"scope"` Factor Factor `bson:"factor"` ProfileVersion string `bson:"profileVersion"` Locale string `bson:"locale"` ExpiresAt time.Time `bson:"expiresAt"` VerifiedAt *time.Time `bson:"verifiedAt,omitempty"` } func (*Record) Collection() string { return "two_factor_challenges" } type Challenge struct { ID string Channel Channel Target string ExpiresAt, ResendAt time.Time } type Proof struct { Token string ExpiresAt time.Time } type Delivery struct { Key string Subject bson.ObjectID Scope Scope Factor Factor Locale, Code string ExpiresAt time.Time } type Choice struct { ID string Channel Channel Target string } type Settings struct { Required bool Preferred string Factors []Choice }