#[non_exhaustive]pub enum Effect {
Show 19 variants
StoreSession {
session: Session,
replaces: Option<TokenHash>,
},
DeleteSession {
token_hash: TokenHash,
},
SetCookie(SetCookie),
RecordFailure {
user_id: UserId,
at: OffsetDateTime,
ip_tag: Option<IpTag>,
},
ClearFailures {
user_id: UserId,
},
RecordStepUpFailure {
token_hash: TokenHash,
},
ClearStepUpFailures {
token_hash: TokenHash,
},
RecordWrongPassword {
key: AccountKey,
},
UseTotpStep {
user_id: UserId,
step: TotpStep,
},
UseRecoveryCode {
user_id: UserId,
hash: RecoveryCodeHash,
},
StoreRecoveryCodes {
user_id: UserId,
hashes: Vec<RecoveryCodeHash>,
},
StoreLinkToken {
token_hash: TokenHash,
link: LinkToken,
},
SendMail(Mail),
Audit(AuditEvent),
RememberDevice {
user_id: UserId,
device_hash: TokenHash,
seen_at: OffsetDateTime,
},
CreateAccount(NewAccount),
StorePassword {
user_id: UserId,
hash: PasswordHash,
},
ActivateAccount {
user_id: UserId,
},
MarkStepUp {
token_hash: TokenHash,
at: OffsetDateTime,
method: SignInMethod,
},
}Expand description
Something the app must do. Carry out every effect of a Transition or Refusal, in
order.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StoreSession
Insert the session. With replaces, delete the session with that token hash in the
same transaction (a stage change issues a new token).
DeleteSession
Delete the session with this token hash.
SetCookie(SetCookie)
Send this Set-Cookie header.
RecordFailure
Count one failure, atomically: UPDATE ... SET failures = failures + 1 ... RETURNING failures (never read-modify-write from the Account snapshot, or
concurrent failures are lost). Then, with the returned count n, store
LockoutPolicy::locked_until(n, at) as
locked_until when it is Some, and append
LockoutPolicy::lockout_event(user_id, n, at, ip_tag) when it is Some.
Fields
at: OffsetDateTimeNow.
ClearFailures
Reset the account’s failure count to 0 and clear locked_until.
RecordStepUpFailure
Count one wrong step-up guess against this session, atomically: UPDATE sessions SET step_up_failures = step_up_failures + 1 WHERE token_hash = ? RETURNING step_up_failures. Only under
StepUpFailures::PerSession. When the guess
reaches the limit the flow also ends the session (with
DeleteSession); an app may end it as soon as the returned
count satisfies
StepUpFailures::ends_session, which also
covers guesses that raced, and otherwise the next step-up from it is refused and ends
it.
ClearStepUpFailures
Reset this session’s step-up failure count to 0, after a step-up succeeded. Only under
StepUpFailures::PerSession.
RecordWrongPassword
Record a wrong password for the throttle
(WrongPasswordThrottle::record).
Fields
key: AccountKeyThe address it counts under.
UseTotpStep
Store step as the account’s last used TOTP step, only if it is newer than the
stored one (compare-and-set); if it is not, the code was raced and the sign-in must
be refused.
UseRecoveryCode
Mark this recovery code used, only if it is still unused (compare-and-set), as above.
StoreRecoveryCodes
Replace the account’s recovery codes with these.
StoreLinkToken
Store a one-time link under its token hash.
SendMail(Mail)
Send this mail.
Audit(AuditEvent)
Append this audit event.
RememberDevice
Remember (or refresh last_seen_at of) the device with this cookie hash for the
account. Forget devices unused for Config::device_ttl.
Fields
seen_at: OffsetDateTimeNow.
CreateAccount(NewAccount)
Create this inactive account; refuse duplicates by email.
StorePassword
Store the account’s new password hash.
ActivateAccount
Mark the account active.
MarkStepUp
Set the session’s authenticated_at and method: the step-up window starts again.