1.4 KiB
1.4 KiB
Implement MFA (TOTP) Support
I will implement Time-based One-Time Password (TOTP) multi-factor authentication, moving further into Phase 5 of the roadmap.
1. Schema Changes
- New Table:
auth.mfa_factorsto store MFA secrets and status.- Columns:
id,user_id,factor_type(e.g., 'totp'),secret,status('unverified', 'verified'),created_at,updated_at.
- Columns:
- Migration: Create a new SQL migration file for this table.
2. Dependencies
- Crate: Add
totp-rstoauth/Cargo.tomlwithqrfeature for generating QR codes.
3. Implementation (auth service)
- New Module:
auth/src/mfa.rs. - Endpoints:
POST /auth/v1/mfa/enroll: Generates a new TOTP secret and returns it (plus QR code). Creates anunverifiedfactor.POST /auth/v1/mfa/verify: Accepts a code and the factor ID. Verifies the code. If correct, marks factor asverified.POST /auth/v1/mfa/challenge: (Optional for MVP) Verifies a code for a verified factor to grant access.
Execution Steps
- Add Dependency: Update
auth/Cargo.toml. - Create Migration: Add the SQL file in
migrations/. - Implement Logic: Create
auth/src/mfa.rswith enrollment and verification logic. - Register Routes: Update
auth/src/lib.rsto include the new MFA endpoints. - Update Roadmap: Mark MFA as completed.