admin管理员组

文章数量:1426072

I have developed an App that uses Firebase. The user has to go through a Wordpress website and buy a subscription before being able to access the App. When a new Wordpress user registers, I would like to create the user in Firebase too with the very same credentials (e-mail/password). I have searched but not found anything to be able to do that. What would be the best solution. Thank you in advance!

I have developed an App that uses Firebase. The user has to go through a Wordpress website and buy a subscription before being able to access the App. When a new Wordpress user registers, I would like to create the user in Firebase too with the very same credentials (e-mail/password). I have searched but not found anything to be able to do that. What would be the best solution. Thank you in advance!

Share Improve this question asked Mar 29, 2019 at 7:51 MikeMike 112 bronze badges 1
  • Has there been any resolution to this? I'm in a very similar situation, searching for the same functionality. Thanks! – Jessica Evans Commented May 23, 2019 at 13:03
Add a comment  | 

2 Answers 2

Reset to default 1

I have no knowledge or experience with Firebase specifically, so I will answer generally as it could be applicable to any external App / User Database synchronization.

The password is the tricky part, as WordPress hashes the password before putting it in the database, and so does not by default store the plain text password anywhere for security reasons. This means you would have to either:

  1. Send the username and password to the App API for storage upon user creation. Then activate those users later when they pay for subscription. However, this may mean you end up with a lot of inactive users in your App (who didn't buy a subscription after signup) which you would probably have to clean up (expire) regularly.

OR

  1. Save the plain text password to user meta upon user creation. Normally this would not be recommended, but if "anyone can register" for a WordPress subscriber account, which you are using to make a "real" membership later, then it's not really much of a security hole - as the free subscriber role has no extra privileges anyway. Then when they make a paid subscription, you can send the stored password to the App API with their membership and make sure to delete it from the user meta.

In either case, you would also need to add some code to synchronize a new password with via the App API in the case that the user changes it through their profile page.

The way you are thinking about it is to use two different identity providers (IdP), Firebase and WordPress, and keep them in sync. This is the most difficult solution to your problem. You really only want to have a single IdP and then use federation to allow users to log into another platform by using that single IdP.

In your scenario you want WordPress to be your IdP and Firebase to use federated IDs. FirebaseUI can be used to allow your application to use federated IDs. It supports both SAML and OpenID Connect which are two different ways you can authenticate your users to an IdP. Now you need a way for WordPress to be able to receive and respond to these requests. You'll be looking for a plugin like this one from miniOrange that has been made to allow you to use WordPress as an IdP and supports federation through SAML or OpenID Connect.

Using both FirebaseUI and a WordPress plugin you can now authenticate all your users to a single account and no longer have to worry about keeping two different login methods in sync.

本文标签: Creating user in Firebase after Wordpress user registration