Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* auth_migration: 20260824000000 */
do $$ begin
alter type {{ index .Options "Namespace" }}.factor_type add value 'recovery_code';
exception
when duplicate_object then null;
end $$;
23 changes: 23 additions & 0 deletions migrations/20260824000001_add_recovery_codes_tables.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* auth_migration: 20260824000001 */
create table if not exists {{ index .Options "Namespace" }}.mfa_recovery_code_sets (
Comment thread
fadymak marked this conversation as resolved.
id uuid primary key,
user_id uuid not null unique references {{ index .Options "Namespace" }}.users (id) on delete cascade,
mfa_factor_id uuid not null unique references {{ index .Options "Namespace" }}.mfa_factors (id) on delete cascade,
failed_verification_count integer not null default 0 check (failed_verification_count >= 0),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about failed_attempts vs. failed_verification_count? thinking this terminology would be a good thing to align on because I'll be adding a similar column as part of the OTP work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion as both make sense. The verification terminology comes from the POST /factors/recovery-codes/verify and the rest of the MFA factors.

It boils down to building the feature around the specific MFA terminology versus having something more generic: #2725 (comment)

verification_locked_until timestamptz,
Comment thread
fadymak marked this conversation as resolved.
Comment thread
fadymak marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wondering if verification_* as a prefix is necessary, or if we could just do locked_until

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for consistency between failed_verification_count and verification_locked_until.

created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
Comment thread
fadymak marked this conversation as resolved.
Comment thread
fadymak marked this conversation as resolved.
);

/* auth_migration: 20260824000001 */
create table if not exists {{ index .Options "Namespace" }}.mfa_recovery_codes (
id uuid primary key,
mfa_recovery_code_set_id uuid not null references {{ index .Options "Namespace" }}.mfa_recovery_code_sets (id) on delete cascade,
code_hash text not null,
Comment thread
fadymak marked this conversation as resolved.
Comment thread
annabkr marked this conversation as resolved.
consumed_at timestamptz,
Comment thread
fadymak marked this conversation as resolved.
created_at timestamptz not null default now()
);

/* auth_migration: 20260824000001 */
create index if not exists mfa_recovery_codes_set_id_idx
on {{ index .Options "Namespace" }}.mfa_recovery_codes (mfa_recovery_code_set_id);
Loading