2016-09-24 39 views
0

如果将此配置集成到JS中,那么这不会是一个安全问题,因为任何人都可以打开JS文件,访问此详细信息并访问我的Firebase DB?需要帮助了解Firebase配置安全性

var config = { 
    apiKey: "xxxx", 
    authDomain: "xxx.firebaseapp.com", 
    databaseURL: "https://xxx.firebaseio.com", 
    storageBucket: "xxx.appspot.com", 
    messagingSenderId: "0000" 
}; 

如何确保它是安全的?

+2

任何可通过互联网访问的数据库都可以通过sone找到。您可以通过设置谁可以访问它以及他们可以做什么的规则来确保数据库的安全。对于Firebase,这些规则在[此处](https://firebase.google.com/docs/database/security/)中进行了说明。另请参阅我的答案在这里:http://stackoverflow.com/questions/35418143/how-to-restrict-firebase-data-modification/35419194#35419194 –

回答

2

这只是让客户端可以识别您的应用程序。即使是apiKey更像是一个参考,并不像一个秘密密码,所以不用担心。您可以使用它在单个文件中实例化许多应用程序。 (见https://firebase.google.com/docs/web/setup)现在

// Intialize the "[DEFAULT]" App 
var mainApp = firebase.intializeApp({ ... }); 

// Intialize a "Secondary" App 
var secondaryApp = firebase.initializeApp({ ... }, "Secondary"); 
... 
mainApp.database().ref("path/to/data").set(value); 
secondaryApp.database().ref("path/to/data").set(anotherValue); 

,火力地堡安全的心脏是火力地堡实时的数据库规则。在此处了解它们: https://firebase.google.com/docs/database/security/

Firebase实时数据库规则以类似JSON的格式表示,所以您应该立即为自己创建一些!