title: Firebase Rules: How to block anonymous access?
body: <p>Reading the Firebase Rules <a href="https://firebase.google.com/docs/storage/security/" rel="noreferrer">Documentation</a> I couldn't find anything on how to block anonymous access to a specific collection or document.</p>
  
  <p>In other words, I want to block users who are not logged in, and I also want to block users who are logged in as anonymous. I want to allow only users who are logged in as themselves (through email, Facebook, Google, SMS, etc).</p>
  
  <p>How can I do that?</p>
  
  <p>This is the code I came up with, which doesn't work:</p>
  
  <pre><code>    service cloud.firestore {
        match /databases/{database}/documents {
          }
          match /collectionExample/{documentExample} {
            allow create: if request.auth.uid != null &amp;&amp; request.auth.token.isAnonymous != false;              
            allow read: if request.auth.uid == resource.data.userId;
          }
        }
      } 
  </code></pre>