skip to Main Content

I am developing a web application using .net Core Web API. So far I have used Identity to authenticate and manage users. Is it often the case and suggested to use an auth service like Google Firebase Auth while still having an own server backend?

I am thinking about using Google Firebase Auth so that users can login in different ways (using Facebook, Google, etc.).
However, I want to have a self hosted backend application and database.
Now I am asking myself:

  1. How do I store user data on my server: Should I use the uid (returned from Firebase) as foreign key to save user related data in my database?

  2. How can I make use of Roles (Identity)? How can I add/remove a Role from a particular user?

  3. Should I store additional user data (like email, name, etc.) in my database or should I always retrieve those infos from the token!? Are those infos provided by Firebase Auth at all?

Thank you for bringing light into the darkness!

2

Answers


    1. You have your own user database. You can verify the Firebase ID token when a user signs in and get your internal users Firebase custom token.

      docs/auth/users

    2. You store them in you own database and add them to you Firebase custom token.

    3. That depends on how much data you need and if the data can differ from the Firebase base data.

    Login or Signup to reply.
  1. Add Firebase to Your app

    <script src="https://www.gstatic.com/firebasejs/4.1.3/firebase.js"></script>
    <script>
      // Initialize Firebase
      // TODO: Replace with your project's customized code snippet
      var config = {
        apiKey: "<API_KEY>",
        authDomain: "<PROJECT_ID>.firebaseapp.com",
        databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
        storageBucket: "<BUCKET>.appspot.com",
        messagingSenderId: "<SENDER_ID>",
      };
      firebase.initializeApp(config);
    </script>
    

    If you haven’t yet connected your app to your Firebase project, do so from the Firebase console.
    Enable Email/Password sign-in:
    In the Firebase console, open the Auth section.
    On the Sign in method tab, enable the Email/password sign-in method and click Save.

    Create a password-based account

    Create a new account by passing the new user’s email address and password to createUserWithEmailAndPassword:

    firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // ...
    });
    

    for more information please go through

    https://firebase.google.com/docs/auth/web/password-auth

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search