2017-10-13 5 views
0

Firestore 규칙을 사용하여 아래 시나리오를 설정하려고합니다.하나의 컬렉션에만 인증되지 않은 액세스를 허용하는 Firestore 보안 규칙

인증없이 사용자가 '제품'컬렉션에 액세스 할 수 있도록하려면 어떻게해야합니까? 다음과 같이 규칙을 넣으려고했지만 작동하지 않습니다. 이 같은

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; 
    } 
    } 
} 
관련 문제