DEV Community

Firebase React Authentication Tutorial

Maksim Ivanov on March 04, 2018

Sometimes you just need to make a fast prototype and you don’t want to mess with back end, authentication, authorization and all of that. Here is w...
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
satansdeer profile image
Maksim Ivanov

Hey Duane, what do you mean "data is stored in network"?

Would he easier to help if youd show an example repo.

Collapse
 
nano1406 profile image
Nano1406

Hi, first of all...great post!! I have one problem...when I refresh the app from a private route the router redirect me to the login page everytime. This happend because when the app renders for the first time, the user isn't authenticated so the only thing to do next is redirect to "/login" but then when the status of the user change to "authenticated" nothing more happend and the app keep in the logine route. I don't know if I miss something or there is something missing in the post...

Collapse
 
pretaporter profile image
Maksim

Hello there! I don't know a lot about firebase. Is i right understand, that credentials for db are accessed on client side code?

Collapse
 
dbanisimov profile image
Denis Anisimov

You're right, API key is public. But there is nothing wrong with it, as in Firebase world the client-side API key is merely an identifier your apps use to talk to Firebase services and the real authorization happens with the help of Firebase Auth + Security rules.

Once the user logs in on the client a short-lived JWT token is issued by Firebase Auth, that token is passed with every request to RTDB, Firestore or Storage and Security Rules are used to authorize or not the action.

You can read more here RTDB and Firestore

Collapse
 
satansdeer profile image
Maksim Ivanov

If I understood you correctly - yes. But it's important to note that you shouldn't commit those to git.

Collapse
 
petecapecod profile image
Peter Cruckshank

Thanks this was great. Just what I was looking for 👍
Now I'm going to try to rewrite it with Hooks 😎