簡體   English   中英

Firestore Ruby:如何進行身份驗證? (沒有權限)

[英]Firestore Ruby: How to authenticate? (permission denied)

我正在嘗試從 ruby 訪問 firestore。一切都已設置並正常工作,除非我對文檔執行讀/寫規則。 沒有權限。

使用ruby firestore gem

驗證客戶端:

creds = Rails.application.credentials.firestore
Google::Cloud::Firestore.configure do |config|
  config.project_id = creds[:config][:projectId]
  config.credentials = creds[:service_account].to_h
  config.emulator_host = "localhost:8888" if Rails.env.development?
end


```rb

@client = Google::Cloud::Firestore.new
@client.col(collection_name).get

這將返回權限被拒絕。 如果我允許對所有文檔進行讀/寫,firestore 會很好地返回文檔……所以這是一個 firestore 規則問題。

那么,如何使用 firestore ruby 對用戶進行身份驗證? 我可以在 ruby firestore admin 中創建令牌...但是在 firestore ruby 中沒有 api 來登錄它們(對嗎?)。

firestore ruby 可以對用戶進行身份驗證嗎? 如果是這樣怎么辦?

任何幫助表示贊賞。

更新:

錯誤是:

GRPC::PermissionDenied: 7:
false for 'list' @ L83. debug_error_string:{UNKNOWN:Error received from peer ipv4:127.0.0.1:8888 {created_time:"2022-11-18T17:44:53.265761-08:00", grpc_status:7, grpc_message:"\nfalse for \'list\' @ L83"}}

正如 @orangesoda 之前在評論中發布的那樣,存在基於此Github 鏈接的模擬器問題。 在生產中部署時,一切都按預期工作。

此外,服務器庫的身份驗證通過 IAM 進行管理。 使用服務帳戶時,服務帳戶必須具有適當的權限/角色才能訪問 Firestore 數據庫(並“繞過”安全規則)。

這僅在(我認為是較舊的)文檔中有詳細說明。

以下是權限/角色及其匹配的 Firestore 操作的列表 這也是大部分Ruby 文檔所在的位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM