Skip to content

fix: support exporting and importing mfaInfo in auth#10705

Open
VishalRaut2106 wants to merge 2 commits into
firebase:mainfrom
VishalRaut2106:fix-auth-mfa-export
Open

fix: support exporting and importing mfaInfo in auth#10705
VishalRaut2106 wants to merge 2 commits into
firebase:mainfrom
VishalRaut2106:fix-auth-mfa-export

Conversation

@VishalRaut2106

Copy link
Copy Markdown

Fixes auth:export and auth:import silently discarding MFA user data (mfaInfo) by explicitly including the 'mfaInfo' key in the allowed JSON extraction and validation fields.

Scenarios Tested

  • JSON auth export correctly contains mfaInfo array (verified with unit tests).
  • JSON auth import successfully parses and validates mfaInfo (verified with unit tests).

Sample Commands

firebase auth:export accounts.json --format=json
firebase auth:import accounts.json --hash-algo=scrypt --hash-key=xxx --salt-separator=xxx --rounds=8 --mem-cost=14

Fixes #10704

### Description
Fixes auth:export and auth:import silently discarding MFA user data (mfaInfo) by explicitly including the 'mfaInfo' key in the allowed JSON extraction and validation fields.

### Scenarios Tested
- JSON auth export correctly contains mfaInfo array (verified with unit tests).
- JSON auth import successfully parses and validates mfaInfo (verified with unit tests).

### Sample Commands
firebase auth:export accounts.json --format=json

Fixes firebase#10704
@google-cla

google-cla Bot commented Jun 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request resolves an issue where auth:export and auth:import dropped mfaInfo data for users with Multi-Factor Authentication enabled. This is fixed by adding mfaInfo to the exported and allowed JSON keys in both accountExporter.ts and accountImporter.ts, supported by new unit tests. The review feedback correctly points out a style guide violation where any[] is used for mfaInfo in the test file, and suggests defining a proper type structure instead.

Comment thread src/accountExporter.spec.ts Outdated
displayName: string;
disabled: boolean;
customAttributes?: string;
mfaInfo?: any[];

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.

medium

According to the repository style guide, we should never use any or unknown as an escape hatch. Please define a proper type/interface or inline the expected structure for mfaInfo instead of using any[].

      mfaInfo?: {
        mfaEnrollmentId: string;
        displayName?: string;
        phoneInfo?: string;
        enrolledAt?: string;
      }[];
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

@VishalRaut2106 VishalRaut2106 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed a missing semicolon on line 36 that was causing the global CI linter check to fail for the entire repository

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.

bug: auth:export and auth:import silently discard MFA user data (mfaInfo)

2 participants