Skip to content

feat(mfa): add schema for recovery codes factor - #2725

Merged
fadymak merged 3 commits into
masterfrom
fm/auth-1526
Sep 1, 2026
Merged

feat(mfa): add schema for recovery codes factor#2725
fadymak merged 3 commits into
masterfrom
fm/auth-1526

Conversation

@fadymak

@fadymak fadymak commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Adds the schemas required to support MFA recovery codes factor.

Note

To avoid long running migration on Auth server startup due to mfa_factors (user_id) where factor_type = 'recovery_codes', we've decided to denormalize the user_id field and add it to the mfa_recovery_code_sets which would provide similar guarantees of a user only allowed to have a single set of recovery codes.

@fadymak
fadymak requested a review from a team as a code owner August 24, 2026 13:52
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql Outdated
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql

@xlgmokha xlgmokha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I left a few questions for you to consider. Otherwise, it looks good to me.

Comment thread migrations/20260824000000_add_recovery_codes_factor_type.up.sql Outdated
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql Outdated
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql Outdated
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql Outdated
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
Comment thread migrations/20260824000001_add_recovery_codes_tables.up.sql
@fadymak
fadymak force-pushed the fm/auth-1526 branch 2 times, most recently from 713c62f to 5f66657 Compare August 31, 2026 09:11
- Adds unique user_id to mfa_recovery_code_sets as a workaround to avoid creating a unique index on mfa_factors (user_id) which would impact large tables.
- Renames fields for consistency
- Adds unique index on mfa_recovery_codes (mfa_recovery_code_set_id, code_hash) to prevent duplicate codes per set.
@fadymak
fadymak merged commit 5e4bec6 into master Sep 1, 2026
11 checks passed
@fadymak
fadymak deleted the fm/auth-1526 branch September 1, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants