【问题标题】:How to set databaseAuthVariableOverride in firebase REST如何在 Firebase REST 中设置 databaseAuthVariableOverride
【发布时间】:2023-03-20 14:40:01
【问题描述】:

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?​​p>

【问题讨论】:

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


    【解决方案1】:

    此功能仅适用于 Firebase 实时数据库的 Admin SDK,它应该在受信任的环境中运行。

    如果您使用的是其他 SDK 或 REST API,它将不可用,因为如果用户可以设置自己的 UID,这将是一个重大的安全风险。

    如果您从受信任的环境中调用 REST API,您可以为该调用 mint a custom token,这基本上会给您相同的结果。

    【讨论】:

      猜你喜欢
      • 2018-10-22
      • 2012-06-03
      • 2021-07-18
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多