sub/domain authentication

3,320 views
Skip to first unread message

My Name Is

unread,
Jan 22, 2018, 9:26:32 PM1/22/18
to Firebase Google Group
Hi

Would it be possible to let users sign up on a subdomain (mypages.domain.com) and then transfer that authenticiation with them when they move to www.domain.com?
And by the same, let them at a later visit simply sign in to that account when they are on www.domain.com and move on to the subdomain when they wish without being logged out?


Bassam

unread,
Jan 23, 2018, 3:29:07 AM1/23/18
to Firebase Google Group
Hey there,
Multi-subdomain Auth state persistence is not yet supported. You would need to implement some mechanism to share that state securely between subdomains.
It would be helpful if you can provide more information on your use case. Do you plan to use other Firebase services like Realtime database or Firestore, etc on these different subdomains or are you using your own backend/database and need a session management solution for that?

Best regards,
Bassam

Jonas Frid

unread,
Feb 1, 2018, 6:13:42 PM2/1/18
to Firebase Google Group
I'm interested in this, too.
I have two apps, one for authors and one for readers (author.mydomain.com / reader.mydomain.com).
Ideally, I'd like a user to only have to sign in once when they move between the domains.
Best regards,
Jonas 

Stephan Smith

unread,
Mar 1, 2018, 2:56:17 PM3/1/18
to Firebase Google Group
I am interested in the same feature. 

Christian Gambardella

unread,
Mar 31, 2018, 8:37:42 PM3/31/18
to Firebase Google Group
I'd like to see this feature as well.
We have two different systems that cannot be on the same host. We want to share the same header (with logged in state) between both hosts.

Christian Gambardella

unread,
Apr 1, 2018, 11:10:17 AM4/1/18
to fireba...@googlegroups.com
I’ve found this library and did some tests with it.

This provides an iframe on the authenticated origin which will then allow your other origins to talk to the iframe using postMessage.

I’ve added the portal server on the origin where I’m logged in.
It’s mostly a blank document that listens to `firebase.auth().onAuthStateChanged`.
The user is still present on the portal server page.

Now my plan would be to allow the portal server to do an api request to my cloud function and pass back a token for tokenAuthentication.
Then the other origin website would use that to login.

I’ll let you know if it works.


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b471b60b-857b-4ef6-89e7-454cf225bf6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

R Aponte

unread,
Apr 25, 2018, 10:18:34 AM4/25/18
to Firebase Google Group
Did that iframe postMessage technique work for you? I'd love to implement similar functionality, and came across the suggestion here: https://stackoverflow.com/a/45067299

Christian Gambardella

unread,
Jun 16, 2018, 3:39:14 PM6/16/18
to Firebase Google Group
Hey it stopped working after safari made changes to prevent user tracking. The iframe cannot access its own indexed db when in an iframe.

and...@ethicaljobs.com.au

unread,
Jan 6, 2019, 10:47:27 PM1/6/19
to Firebase Google Group
We are very interested in this use-case. Having a single sign in domain to manage auth accross multiple apps (the same as google does) would be amazing!

accounts.myapp.com - would manage auth for:

Andrew Mclagan

unread,
Jan 6, 2019, 11:45:28 PM1/6/19
to Firebase Google Group
Thats what I'm actually asking. 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Ensys Corp. on Google Cloud

unread,
Jan 7, 2019, 1:43:01 PM1/7/19
to webmasterswebkori
you have start auth with the root domain in that case..
...

Cloud Partner Team
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States



Jonas Frid

unread,
Jan 8, 2019, 10:08:51 AM1/8/19
to fireba...@googlegroups.com
You mean that this is already possible?

You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/LL4p41s4a4I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Romel Gomez

unread,
Feb 22, 2019, 2:55:37 PM2/22/19
to Firebase Google Group
This is currently possible? 

auth.example.com  >>  login here    [Angular App] 
   account.example.com                      [Angular App] 
   dashboard.example.com                 [Angular App]  
   appX.example.com                          [Angular App] 
 

As alternative I thinking in implement an lambda to handle this case in this way: 

1) After the client login successfully in auth.example.com, get an IdToken

firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
 
// Send token to your backend via HTTPS
 
// ...
}).catch(function(error) {
 
// Handle error
});

2) Set an HEADER with the token and Redirect to account.example.com (app 2)  

3) if the user the app 2 is not logged, check the HEADER for the token    

4) Send the token to the lambda or backend via HTTPS

5) Verify the token in the lambda  

# id_token comes from the client app (shown above)

decoded_token
= auth.verify_id_token(id_token)
uid
= decoded_token['uid']

6) Create a new token using firebase admin, and return it.  

uid = 'some-uid'

custom_token
= auth.create_custom_token(uid)


7) Sing in using custom token on the app2 client 

firebase.auth().signInWithCustomToken(token).catch(function(error) {
 
// Handle Errors here.
 
var errorCode = error.code;
 
var errorMessage = error.message;
 
// ...
});


If this approach is O.K don't introduces security issues?  


PD: I have old django app, and I'm using the strangler pattern to migrate the current users accounts, the strangler facade will be auth.example.com that will call to django rest framework to create the session to. I doing good with the approach here? 

Bassam

unread,
Feb 22, 2019, 4:28:02 PM2/22/19
to Firebase Google Group
Hey Romel, we don't support cross domain/subdomain authentication.
Your solution has multiple issues. Here are a few:
The step where you "Set an HEADER with the token and Redirect to account.example.com (app 2) " is subject to session fixation where an attacker can trick an unsuspecting user to inject the attacker's token to an unsuspecting user's session.
Also you don't set time limits on this. Since a Firebase session is indefinite, you need to only allow the exchange of ID token (that is recently authenticated) to custom token within a small window after authentication. Otherwise any leaked token for a session that is quite old can be exchanged for a custom token.

Bassam

John Carroll

unread,
Mar 8, 2019, 11:14:32 PM3/8/19
to Firebase Google Group
So after much fiddling I've gotten Firebase Authentication to work across subdomains. I wrote up a blog post giving a high level overview about how to do it. It's not super easy, but it's also not super hard. Definitely a pain point in my Firebase adoption experience though.


On Monday, January 22, 2018 at 6:26:32 PM UTC-8, My Name Is wrote:

will

unread,
Jun 3, 2019, 1:10:23 PM6/3/19
to Firebase Google Group
Thanks for your post, John. It would be nice if Firebase could support it natively, though.

Joe Bay

unread,
Mar 16, 2020, 11:11:22 AM3/16/20
to Firebase Google Group
Hey all, 

Does this look like something firebase will add in the future? I've looked into the workaround it just seems a bit excessive and territory I rather not mess with.

Thanks! 


On Monday, January 22, 2018 at 6:26:32 PM UTC-8, My Name Is wrote:

Ke Deng

unread,
Mar 20, 2020, 5:32:28 PM3/20/20
to fireba...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages