firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.85k stars 893 forks source link

FR: authentication for server side rendering #2096

Open Siilwyn opened 5 years ago

Siilwyn commented 5 years ago

Environment

Problem

Trying to use Firebase Auth in combination with Server Side Rendering (in Nuxt). The server renders the requested page, and in order to do that it needs to fetch data from Firestore which in turn requires authentication. The page code is isomorphic, on initial request it runs on both the server and client using the JS SDK. Giving the advantages of SSR combined with the benefit of following Firestore rules.

My current solution is to generate a custom token from a refresh token which is pretty slow since three (http) requests are needed in-between to achieve this. Then logging in using signInWithCustomToken, diagram to clarify: firebase_auth_ssr_nuxt2

My request would be to make it possible to sign in using a refresh token, if possible? Or add something else to support this use-case.

blitzbohne commented 5 years ago

Same issues here :(

Siilwyn commented 5 years ago

@alpfactory-alex please add a '+1' (:+1:) reaction to the main issue post so this gets more visibility.

Siilwyn commented 5 years ago

Bump, @schmidt-sebastian thoughts?

ryanpbrewster commented 5 years ago

Question: if you could configure the Node.js admin SDK to act as a specific user rather than as an admin, would that suffice for your needs?

Siilwyn commented 5 years ago

@ryanpbrewster partly maybe, it would still require some working around the issue but it will be only one request. However the JS SDK would need to be able to authenticate with an auth token too.

Assume I could then use the Node.js admin SDK to get a user specific auth token and pass it to the front-end:

  1. make call to serverless function passing the user refreshToken
  2. in the serverless function validate the token and give back an user auth token using the Node.js admin SDK
  3. use the auth token in the front-end (but that is not possible)
honi commented 4 years ago

Question: if you could configure the Node.js admin SDK to act as a specific user rather than as an admin, would that suffice for your needs?

This is exactly what I'm looking for. Do you have any updates if this is actively being worked on or at least in the roadmap?

suryacaprice commented 4 years ago

I am having a similar issue for a batch job which would run for over 5 - 6 hours and the token expires and there is currently no way to refresh it . This is really an oversight from the Firebase team to have an authentication system without proper refresh token system working. Compared to it Cognito and other auth systems are way more superior and provide more advanced use case scenarios . If anyone is starting a new enterprise-class application that would require a long-running job for huge data I would strongly recommend going with Cognito or some mature system rather than a weak firebase. Seems this issue was there from its inception and the firebase team still fails to address it and a great hindrance for our app and many others like us.

matallui commented 1 year ago

@avolkovi @hsubox76 Any chance this would be worked on any time soon? It's 2023, most web apps use SSR, and Firebase SDK still doesn't seem to provide a solution for this.