Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getUser() return value contains passwordHash and passwordSalt #501

Open
hiranya911 opened this issue Apr 9, 2019 · 10 comments
Open

getUser() return value contains passwordHash and passwordSalt #501

hiranya911 opened this issue Apr 9, 2019 · 10 comments

Comments

@hiranya911
Copy link
Contributor

The UserRecord returned by admin.auth().getUser() contains passwordHash and passwordSalt fields.

const admin = require('firebase-admin')
admin.initializeApp();
admin.auth().getUser(uid)
  .then((user) => console.log(user));

This resulted in:

UserRecord {
  uid: 'e1b2NmnasZXw0QtpYFcZ88IeK5t1',
  email: '********@gmail.com',
  emailVerified: true,
  displayName: undefined,
  photoURL: undefined,
  phoneNumber: undefined,
  disabled: false,
  metadata: 
   UserMetadata {
     creationTime: 'Wed, 03 Apr 2019 23:36:27 GMT',
     lastSignInTime: 'Thu, 04 Apr 2019 00:38:10 GMT' },
  providerData: 
   [ UserInfo {
       uid: '********@gmail.com',
       displayName: undefined,
       email: '********@gmail.com',
       photoURL: undefined,
       providerId: 'password',
       phoneNumber: undefined } ],
  passwordHash: 'UkVEQUNURUQ=',
  passwordSalt: undefined,
  customClaims: undefined,
  tokensValidAfterTime: 'Wed, 03 Apr 2019 23:36:27 GMT' }

This is contrary to the documented behavior:

passwordHash
(string or undefined)

The user’s hashed password (base64-encoded), only if Firebase Auth hashing algorithm (SCRYPT) is used. If a different hashing algorithm had been used when uploading this user, as is typical when migrating from another Auth system, this will be an empty string. If no password is set, this is null. This is only available when the user is obtained from listUsers().

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@LilJaaY
Copy link

LilJaaY commented Aug 16, 2019

Is there any other way to get the password hash?

@zerobytes
Copy link

You can get passwordHash and passwordSalt using the listUsers method from admin auth api

@baotran-bryan
Copy link

google does not fix this, right?

@akashgangrade
Copy link

akashgangrade commented Jul 22, 2020

@hiranya911: Which firebase-admin version are you using?

@Acterion
Copy link

documented behavior

Can confirm this is still an issue in this setup:

    "firebase": "9.6.4",
    "firebase-admin": "10.0.2",
    "firebase-functions": "3.16.0",

@Randima-Lahiru
Copy link

I'm also have same problem.
admin.auth().getUser return passwordHash and passwordSalt parameter with undefined. But I can get value for those parametes using admin.auth().listUsers
How can I get passwordHash and passwordSalt values using admin.auth().getUser

@luizfelipelaviola
Copy link

This makes no sense. I just want to get a single user password hash to match using firebase admin and I need to pull the entire user list to do it. Can you imagine charging the app with millions of user entries just to get only single entity property from one position? It's also heavy for Firebase servers at all...

@soknifedev
Copy link

is there any update on this?

@alexpechkarev
Copy link

Hi, please can we have an update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

13 participants