2017-10-26 16 views
1

当社のデータベース構造は以下のようになります。私たちは、ドキュメントからの読み取りのためのいくつかのルールを作成しようとしましたFirestoreセキュリティルール、ネストされたフィールド

trips 
    12345 
     toArea 
     radius: 150 
     name: "citycenter" 
    54321 
     toArea 
     radius: 250 
     name: "main street" 

:それは

match /chats/{trip} { 
    match /messages/{message} { 
     allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea != null 
    } 
} 

正常に動作します

次のルールは機能しません:

allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea != null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea.radius != null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea.radius == null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea["radius"] == null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea["radius"] != null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data["toArea.radius"] == null 
allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data["toArea.radius"] != null 

私は本当に何が間違っているのか分かりません。逆の2つのルール(== null /!= null)はどうやって動作しませんか?どのように我々はフィールドでtoArea.radiusのルールで管理できますか?

+0

try '.data.toArea.data.radius' – Hareesh

+0

現在、ルールのネストされたプロパティに問題があります。これはほとんど間違いではありません。私たちは可能な限り迅速に修正プログラムを公開しています。ご理解いただきありがとうございます。 –

+0

それは一貫して '.data.field.data'ですか? – iiylll

答えて

2

EDIT(12/18/17):これは両方とも修正されているので、これはJust Work™です。 resource.dataたり、ルール内のどこかにrequest.resource.dataへの参照があるかどう

  1. get().dataのみ(我々が使用した作品

    は@hatboysamあなたは現在、私たちが解決するために迅速に取り組んでいる2個のバグをヒットしている、前述のようにget()dataを使わずにresourceを返していましたが、問題が発生してリリース直前に変更されました。

  2. ネストされたプロパティ(例:toArea.radius)が破損しています。

1を回避するには簡単です:

match /chats/{trip} { 
    match /messages/{message} { 
     allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea != null 
    } 
} 
match /bogusPathThatWillNeverMatch { 
    allow read: if resource.data != null; // should never be true 
} 

1と2の両方がすぐに固定されるので、解像度をお楽しみに。

+1

@ mike-mcdonaldこの問題のアップデートを購読できるバグトラッカーの指示にお答えください。 :-) – sindrenm

関連する問題