2017-10-13 6 views
0

Firestoreのルールの助けを借りて、以下のシナリオを確立しようとしています。Firestoreセキュリティルールは1つのコレクションにのみ認証されないアクセスを許可します

「製品」コレクションに認証なしでアクセスできるようにするにはどうすればよいですか?私はルールを以下のように入れてみましたが、うまくいきません。

service cloud.firestore { 
    match /databases/{database}/documents { 
    // All should be able to access products collection 
    match /products { 
     allow read; 
    } 
    // All other collection should only be accessed if user is authenticated. 
    match /{document=**} { 
     allow read, write: if request.auth != null; 
    } 
    } 
} 
+0

を私はあなたが '一致/製品/ {文書= **}' –

+0

公共のコレクションがある場合はどう/ショップ/ {shopId} /製品が必要だと思います –

+0

それから、おそらく、/ shop/{shopId}/products/{document = **} ' –

答えて

0

このような何かが動作します:

service cloud.firestore { 
    match /databases/{database}/documents { 
    // All should be able to access products collection 
    match /products/{allProducts=**} { 
     allow read; 
    } 
    // All other collection should only be accessed if user is authenticated. 
    match /{notProducts}/{allNotProducts=**} { 
     allow read: if notProducts != "products" 
        && request.auth != null; 
    } 
    } 
} 
関連する問題