Data structure
Entities (tables)
Authentication factors
This entity defines authentication factors entity information structure:
Column | Type | M/O | Purpose |
---|---|---|---|
id | uuid | M | |
user_id | uuid | M | User FK |
type | varchar | M | |
factor | varchar | O | Factor value |
is_active | boolean | M | |
inserted_at | timestamp | M | |
updateed_at | timestamp | M |
type | factor |
---|---|
SMS | "+380677778899" |
PHONE | "+380677778899" |
"pupkin.vasya@gmail.com" |
Users
This entity enrich a few attributes:
Store counters parameters for 2FA in `users.priv_settings` as structure :
{
"login_error_counter"
:
0
,
"otp_error_counter"
:
0
}
Information about blocked directly in entity `users`.
Column Type Purpose is_blocked boolean block_reason varchar (255), NULL
OTP
This entity defines OTP (one tome passwords) entity information structure:
Column | Type | M/O | Purpose |
---|---|---|---|
id | uuid | M | |
key | varchar | M | Value of factor (1 active 2FA for user) |
code | varchar | M | Value of OTP |
status | varchar | M | Status (Dictionary: OTP_STATUS) |
code_expired_at | timestamp | M | Timestamp which OTP expired (now() + param from config) |
attempts_count | integer | O | Count of trying OTP authorization process |
updateed_at | timestamp | M |
OTP states
Dictionary: `OTP_STATUS`
Value Purpose NEW Initial status for newest OTP item. Ready to use in OTP verification process. VERIFIED Status for successful OTP verification process UNVERIFIED Status for unsuccessful OTP verification process EXPIRED Expired after OTP lifetime. CANCELED Status for manual admin action.
- Status Chart for OTP
- TransitionsFromTransitionResult
Created new OTP status = NEW status = NEW Succseful OTP verify status = VERIFIED status = NEW Unsuccseful OTP verify afterexcess of count [param: OTP_ERROR_MAX] status = UNVERIFIED status = NEW [AUTO] Termination process after end of life-time OTP [param: OTP_LIFETIME] status = EXPIRED status = NEW All OTP by `key` in status=`NEW` before creating new OTP status = CANCELED
Сonstraints
Authentication factors
- user have one active 2FA factor ( one of any type)
- unique index on user_id+type