c# - 如何在 Firebase REST 中设置 databaseAuthVariableOverride
问题描述
Firebase 具有允许使用自定义身份验证变量初始化连接的功能。
示例中的链接:
# Fetch the service account key JSON file contents
cred = credentials.Certificate('path/to/serviceAccountKey.json')
# Initialize the app with a custom auth variable, limiting the server's access
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://databaseName.firebaseio.com',
'databaseAuthVariableOverride': {
'uid': 'my-service-worker'
}
})
我正在使用 c#,没有针对该语言的 SDK ...。我选择使用 REST API,但我没有在文档中找到如何使用上述代码中的功能。
有一种方法可以在 REST for Firebase 中使用 databaseAuthVariableOverride?
解决方案
此功能仅在 Firebase 实时数据库的 Admin SDK 中可用,它应该在受信任的环境中运行。
如果您使用的是其他 SDK 或 REST API,它将不可用,因为如果用户可以设置自己的 UID,这将是一个重大的安全风险。
如果您从受信任的环境中调用 REST API,则可以为该调用创建一个自定义令牌,这基本上会给您相同的结果。
推荐阅读
- asp.net - ConfigurationManager.AppSettings 正在工作
but not for <asp:Label></h1> <div id="body"><p>I get value from web.config for <code><title></code> and <code><asp:Label></code>.<BR /> In case - excel - 在其他工作表中查找日期
- java - 无法为接口 android.app.IAlarmManager 调用无参数构造函数
- google-tag-manager - 验证后的 Google 跟踪代码管理器触发器 - 页面路径或页面 URL 星标不起作用
- jsp - 在 EL 中使用 getter 而不是字段名更安全吗?
- java - 如何处理数组类型的Java默认构造函数参数?(没有静态工厂方法或构建器模式)
- angular - 如何在 Angular 8.2.14 中正确使用 ngStyle?
- python - Python - 如何通过 for 循环组合数据帧?
- python - 理解 Python 中的访问器和修改器
- java - 如何将日期字符串转换为 joda DateTime?