title: Firestore permissions
body: <p>How do I configure permissions so that a user can only read and write documents where they are the owner?
  my documents have a top level attribute called owner.</p>
  
  <p>I read these docs<br>
  <a href="https://firebase.google.com/docs/firestore/security/secure-data?authuser=0#the_resource_variable" rel="nofollow noreferrer">https://firebase.google.com/docs/firestore/security/secure-data?authuser=0#the_resource_variable</a></p>
  
  <p>and it seems like this should work?</p>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
      match /analysis/{analysis} {
        allow read, write: if request.auth.email == resource.data.owner
      }
    }
  }
  </code></pre>
  
  <p>however this doesn't seem to work. i continuously get insufficient permission error.
  What do i need to change?</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>After reading the docs @Doug Stevenson linked I decided to go with </p>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
      match /analysis/{analysis} {
        allow read, write: if request.auth.uid == resource.data.owner_uid;
      }
    }
  }
  </code></pre>
  
  <p>So my original intent was that when we do a list operation:  </p>
  
  <p><strong>a.</strong> only those documents belonging to a user are returned<br>
  <strong>b.</strong> only documents a user owns can be read or written by that user.  </p>
  
  <p>With the above configuration <strong>b.</strong> is accomplished.<br>
  how do I do accomplish <strong>a.</strong> ?</p>