Cris
Cris

Reputation: 464

Can we provide our own uid for a Firebase database if we use our own authentication?

We are required to use our own authentication in our App.

Can Firebase authentication services pass through user entered credentials to our authentication services so that Firebase authorization uid can be set and we can use Firebase Database rules such as:

/ These rules grant access to a node matching the authenticated
// user's ID from the Firebase auth token
{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Upvotes: 0

Views: 276

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598887

The flow is different from what you seem to assume. If you use custom authentication, it is up to you to control the authentication flow. Then when you've authenticated the user, you mint a token and pass that back to the app. The app then uses this token to authenticate with Firebase Authentication.

If you mint your own tokens, you fully control the uid of the user. In fact that's the only thing that is really required: a UID to identify the user.

Upvotes: 2

Related Questions