我的 Firebase 数据库的以下规则允许通过我的 iOS 应用进行匿名登录。
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"locations": {
".indexOn": "g"
}
}
}
效果很好,但现在我需要添加对通过 apiKey 工作的 JS Web 应用程序的访问权限。如何在此处添加该规则?
最佳答案
您可以在 JS Web 应用程序上匿名登录吗?我从 https://firebase.google.com/docs/auth/web/anonymous-auth 复制了这段代码
firebase.auth().signInAnonymously().catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
如果您不想登录(我认为您不想登录),只需替换
auth != null
与
true
关于javascript - Firebase 数据库安全规则允许匿名访问和 Web 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41537210/