Feature Request: Support server-side authentication in AngularFireAuth #1500
AnthonyNahas
started this conversation in
Ideas
Replies: 24 comments 8 replies
-
|
I have the same problem, looking for solution of this scenario :) if we can fix this, it will be completed eco system for angular with minimum cost. what about angular state transfer ? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
While not an official solution, I have used dependency injection + firebase admin to work on server side See: The idea is, you only need to use the |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently developing an angular universal app powered by firebase and angularfire2 (for authentication and database/firestore).
For the server side rendering i am using NodeJS.
I have the following scenario:
There is many routes and many components inside the project! For the following scenario i will consider only 3 routes/components
1- Home Component (authentication is not required)
2- UserProfile Component (Authentication is required)
3- Login Component (used as fallback route to authenticate the user that are trying to access the user profile without to be logged in)!
To make things working with an authentication process within an angular app, we use the "canActivate guard"!
Workflow in the canActivate guard:
this.auth.user$ is equal to
However, client side rendering is working like expected but no the server side!
Since in nodejs the firebase authentication's credentials are not known, the user$ Observable is never fired on the server side (the credentials are located in the local storage of the browser under the key firebase:authUser......).
Angular Universal - SSR - canActivate Result:
when the guard is triggered on the server side, the login page will be rendered and then after few seconds the client side render the whole thing again and will be redirected to the user page.
Than means, by refreshing and rendering every time the user will see first the login page then the user page! This is happening one more time because on the server side are NEVER authenticated..
How can we solve the above described scenario?
Request
Please support firebase authentication on the server side too
Note (ideas): supporting firebase authentication for angular universal app through JWT - headers / cookies ????
Beta Was this translation helpful? Give feedback.
All reactions