如果我只将它用于分析和崩溃,我是否需要在 Firebase 中设置安全规则?
Do i need to set up security rules in Firebase, if i only use it for analytics and crashes?
首先:
我目前仅将 Firebase 用于分析(用户数)和移动应用程序崩溃。未使用 Firebase 存储、实时数据库或 Firestore(none 已配置或设置)。
问题:
我还需要在 Firebase 中定义一些安全规则吗?
创建 Firebase 项目时,不会自动创建数据库和存储桶。因此,在这一点上,它们不存在被恶意用户滥用的风险。
如果您通过控制台创建数据库或存储桶,它会询问要应用哪些安全规则。如果您 select 那里的限制性规则(其中包含 false
的那些,数据库或存储桶将无法访问,因此也不存在滥用风险。
如果您(不小心)选择了更宽松的规则,用户可以访问您的数据库或存储桶,即使您的应用程序不能访问。在这种情况下,您需要设置最严格的规则:
实时数据库
{
"rules": {
".read": false,
".write": false
}
}
Firestore
// Deny read/write access to all users under any conditions
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
存储空间
// Access to files through Firebase Storage is completely disallowed.
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}
首先:
我目前仅将 Firebase 用于分析(用户数)和移动应用程序崩溃。未使用 Firebase 存储、实时数据库或 Firestore(none 已配置或设置)。
问题:
我还需要在 Firebase 中定义一些安全规则吗?
创建 Firebase 项目时,不会自动创建数据库和存储桶。因此,在这一点上,它们不存在被恶意用户滥用的风险。
如果您通过控制台创建数据库或存储桶,它会询问要应用哪些安全规则。如果您 select 那里的限制性规则(其中包含 false
的那些,数据库或存储桶将无法访问,因此也不存在滥用风险。
如果您(不小心)选择了更宽松的规则,用户可以访问您的数据库或存储桶,即使您的应用程序不能访问。在这种情况下,您需要设置最严格的规则:
实时数据库
{
"rules": {
".read": false,
".write": false
}
}
Firestore
// Deny read/write access to all users under any conditions
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
存储空间
// Access to files through Firebase Storage is completely disallowed.
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}