How do I lock down Firebase Database to any user from a specific (email) domain?
<p>I have a small, personal Firebase webapp that uses Firebase Database. I want to secure (lock down) this app to any user from a single, specific domain. I want to authenticate with Google. I'm not clear how to configure the rules to say "only users from a single, specific domain (say <code>@foobar.com</code>) can read and write to this database".</p>

<p>(Part of the issue that I see: it's hard to bootstrap a Database with enough info to make this use case work. I need to know the user's email at the time of authentication, but <code>auth</code> object doesn't contain email. It seems to be a chicken-egg problem, because I need to write Firebase rules that refer to data in the Database, but that data doesn't exist yet because my user can't write to the database.)</p>

<p>If <code>auth</code> had email, then I could write the rules easily.</p>

<p>Thanks in advance!</p>