将Firebase安全限制为特定的Google Apps域?

Wil*_*age 9 firebase-security firebase-realtime-database

我目前正在寻求将Firebase用于内部应用程序,该内部应用程序只能由拥有我们组织的Google帐户的员工访问.

我理解如何限制只对谷歌登录的读/写访问,例如

{
  "rules": {
    ".read": "auth.provider === 'google'",
    ".write": "auth.provider === 'google'"
  }
}
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚如何限制对Google帐户中特定域/组织的访问.我知道这可以在应用程序级别完成,但考虑到我们用来访问数据库的通道数,我想在数据库级别强制执行auth,以及应用程序级别.

有没有人这样做过?谢谢.

Fil*_*las 12

您可以使用以下命令限制对gmail域的访问:

{
  "rules": {
    ".read": "auth.token.email.endsWith('domain.com')",
    ".write": "auth.token.email.endsWith('domain.com')"
  }
}
Run Code Online (Sandbox Code Playgroud)