Skip to content

fix(auth): Clear redacted password hashes returned by list_users() - #1008

Open
0z5a wants to merge 1 commit into
firebase:mainfrom
0z5a:fix/redacted-password-hash
Open

0z5a wants to merge 1 commit into
firebase:mainfrom
0z5a:fix/redacted-password-hash

Conversation

@0z5a

@0z5a 0z5a commented Nov 15, 2026

Copy link
Copy Markdown

ExportedUserRecord.password_hash is supposed to return None when the backend redacts the hash (it sends base64("REDACTED"), i.e. the string "UkVEQUNURUQ="). The marker constant was base64.b64encode(b'REDACTED'), which is bytes, while the value parsed from the JSON response is a str. In Python 3 these never compare equal, so the placeholder was returned as if it were a real hash.

This change makes B64_REDACTED a str so the comparison matches what the API actually returns. This is the same comparison the Node.js SDK does.

Testing: test_redacted_passwords_cleared built the record with a bytes value, which a JSON response can never contain, so it passed even though the real case was broken. It now uses the string form. I also added test_list_users_redacted_password_hash, which goes through auth.list_users() with a mocked JSON response containing one redacted and one real hash. Both tests fail on main and pass with this change. pytest tests/test_user_mgt.py passes, and ./lint.sh reports no issues.

Fixes #1007

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

Context Sources Used:

  • id: firebase-admin-python

B64_REDACTED was the bytes value base64.b64encode(b'REDACTED'), but the
passwordHash field of the JSON response is a str, so the comparison was
always false and ExportedUserRecord.password_hash returned the
"UkVEQUNURUQ=" placeholder instead of None when the service account
cannot read password hashes.

Make B64_REDACTED a str and feed the existing test a str value, as the
API returns it.
@0z5a
0z5a requested a review from a team November 15, 2026 00:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 updates the B64_REDACTED constant in firebase_admin/_user_mgt.py to be a decoded string instead of a bytes object. It also updates the test suite to match this change and adds a new test test_list_users_redacted_password_hash to ensure that redacted password hashes are correctly cleared when listing users. There are no review comments, and we have no feedback to provide.

This branch has not been deployed

No deployments
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.

ExportedUserRecord.password_hash returns the redacted placeholder instead of None

1 participant