【问题标题】:Need help in understanding Firebase config security在理解 Firebase 配置安全方面需要帮助
【发布时间】:2016-09-24 07:12:05
【问题描述】:

如果有人将此配置集成到 JS 中,这不会是一个安全问题,因为任何人都可以打开 JS 文件,访问此详细信息并访问我的 firebase 数据库?

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

如何确保其安全?

【问题讨论】:

  • 任何可以通过互联网访问的数据库,sone 都可以找到。您可以通过设置有关谁可以访问它以及他们可以做什么的规则来确保您的数据库安全。对于 Firebase,这些规则描述为 here。也可以在这里查看我的答案:stackoverflow.com/questions/35418143/…

标签: firebase firebase-realtime-database firebase-authentication


【解决方案1】:

这只是为了让客户可以识别您的应用。甚至 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); 

现在,Firebase 安全性的核心是 Firebase 实时数据库规则。在这里学习它们: https://firebase.google.com/docs/database/security/

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多