Hi people! Anyone using Firebase to manage auth in their projects?
I'm wondering about how can I manage the sync between the client SDK where the user does the registration and the backend where I have the DB with users. Sadly I didn't find any "official" answer for that so the first thing that comes to my mind is "easy, take the response from Firebase SDK and do a request to the backend" but honestly I find that solution a bit flaky.
Have you ever had this issue?
c
chrisjenx
08/01/2024, 7:19 PM
We use client side sdk to get the barer auth token, then use firebase on the backend to use it to authenticate the user (the backend admin sdk can pull the prinicpal id and authenticate the token)
chrisjenx
08/01/2024, 7:21 PM
But not sure what you mean by "sync" in relation to auth
a
Antonio Acuña Prieto
08/01/2024, 9:01 PM
I mean, the user is registered in Firebase but the backend didn't notice yet and probably you want a new record for this user in the database. I'm looking for strategies to achieve that
c
CAB
08/02/2024, 11:11 AM
We are in the similar position using CAS. The solution, working for us is:
1. user authenticating with authenticating with authority system to get the ticket
2. Client get redirected to the server application to do SSO with that ticket
a. server checking with Authority system the validity of the ticket
b. if user
doesn’t exist in the DB, then server pulls the principal info and saves it in the local DB
This is how user get created in the server’s DB at the first login. Also, at that time server can validate that user’s info didn’t change (whatever info was coped from the principal).
c
chrisjenx
08/05/2024, 10:55 PM
Oh yeah, just when you call the user lookup the principle User Id in your DB if they don't exist then grab from firebase. Firebase does also support hooks:
https://firebase.google.com/docs/functions/auth-events
SO your server can listen to user events