How can I compare 2 record for permission (Firestore-Rule)Is it possible to set storage rules using firestore of Firebase?Firestore security rule get() not workingFirestore security rules for `list` requestFirestore security rules with spaces in pathValidate map keys in Firestore rulesFirestore rule to read collectionFirestore Rules Simulator - Resource undefinedDoes firestore rule simulator account for existing documents actual collections?Firestore create security rule not behaving as expectedDynamic Firestore rules?

How do I get a cleat that's stuck in a pedal, detached from the shoe, out?

The term for the person/group a political party aligns themselves with to appear concerned about the general public

Is the capacitor drawn or wired wrongly?

Coding Challenge Solution - Good Range

Why would Lupin kill Pettigrew?

Are academic associations obliged to comply with the US government?

Order by does not work as I expect

Why is Colorado so different politically from nearby states?

Why does the UK have more political parties than the US?

Can The Malloreon be read without first reading The Belgariad?

How can a single Member of the House block a Congressional bill?

TV show or movie: Diseased people are exiled to a spaceship

What are the problems in teaching guitar via Skype?

How to properly maintain eye contact with people that have distinctive facial features?

The qvolume of an integer

Why were the Night's Watch required to be celibate?

How to write a vulnerable moment without it seeming cliche or mushy?

Does Peach's float negate shorthop knockback multipliers?

Recording the inputs of a command and producing a list of them later on

How can I offer a test ride while selling a bike?

How do I get a list of only the files (not the directories) from a package?

Bringing Food from Hometown for Out-of-Town Interview?

What is a natural deduction proof from ~(A↔B) to ~(A→B)?

How can I grammatically understand "Wir über uns"?



How can I compare 2 record for permission (Firestore-Rule)


Is it possible to set storage rules using firestore of Firebase?Firestore security rule get() not workingFirestore security rules for `list` requestFirestore security rules with spaces in pathValidate map keys in Firestore rulesFirestore rule to read collectionFirestore Rules Simulator - Resource undefinedDoes firestore rule simulator account for existing documents actual collections?Firestore create security rule not behaving as expectedDynamic Firestore rules?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm defining rules for my firestore database and i stuck there.
I have an post collection and an userProfile collection. If a user banned you you can't reach his post. You can reach which user shared the post under 'document/user'



So I try this command but not worked. When i simulate it every one get reject.



match /posts/currentDocument 
allow read: if !exists(
/databases/$(database)/documents/userProfile/$(request.auth.uid)/banned/
$(/databases/$(database)/documents/posts/$(currentDocument)/user)
)



So I wantto accept everyone's read request except banned users.










share|improve this question






























    0















    I'm defining rules for my firestore database and i stuck there.
    I have an post collection and an userProfile collection. If a user banned you you can't reach his post. You can reach which user shared the post under 'document/user'



    So I try this command but not worked. When i simulate it every one get reject.



    match /posts/currentDocument 
    allow read: if !exists(
    /databases/$(database)/documents/userProfile/$(request.auth.uid)/banned/
    $(/databases/$(database)/documents/posts/$(currentDocument)/user)
    )



    So I wantto accept everyone's read request except banned users.










    share|improve this question


























      0












      0








      0








      I'm defining rules for my firestore database and i stuck there.
      I have an post collection and an userProfile collection. If a user banned you you can't reach his post. You can reach which user shared the post under 'document/user'



      So I try this command but not worked. When i simulate it every one get reject.



      match /posts/currentDocument 
      allow read: if !exists(
      /databases/$(database)/documents/userProfile/$(request.auth.uid)/banned/
      $(/databases/$(database)/documents/posts/$(currentDocument)/user)
      )



      So I wantto accept everyone's read request except banned users.










      share|improve this question
















      I'm defining rules for my firestore database and i stuck there.
      I have an post collection and an userProfile collection. If a user banned you you can't reach his post. You can reach which user shared the post under 'document/user'



      So I try this command but not worked. When i simulate it every one get reject.



      match /posts/currentDocument 
      allow read: if !exists(
      /databases/$(database)/documents/userProfile/$(request.auth.uid)/banned/
      $(/databases/$(database)/documents/posts/$(currentDocument)/user)
      )



      So I wantto accept everyone's read request except banned users.







      firebase google-cloud-firestore firebase-security-rules






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 14:35









      Frank van Puffelen

      255k32410436




      255k32410436










      asked Mar 24 at 10:45









      Uğur CanbulatUğur Canbulat

      66




      66






















          1 Answer
          1






          active

          oldest

          votes


















          0














          It depends on how you're trying to read from the collection.



          If you're trying to read a specific document (e.g. /posts/post123) that is not from a banned user, the read should work. And if you're trying to read a specific document from a banned user, the read should be rejected.



          If you're trying to read the entire /posts collection, that will indeed fail with the above security rules. The reason for that is that security rules don't filter your data; they merely ensure that the read operation only tries to read data that it's authorized for. And reading all of /posts is not authorized, since there are certain documents that are not readable.



          To read all posts from unbanned users, you'll need to attach a listener that only tried to read those documents. In pseudo-code that would be something like:



          db.collection('posts').where('user', 'not in', '/bannedusers')


          But this unfortunately isn't possible in Firestore since it'd require a server-side join, which would make it impossible for Firestore to meet its performance guarantees.



          But say for example that you have an approval flow, where each post needs to be approved before it can be read by other users. In that case you could enforce this in your security rules with:



          // anyone can read approved posts, but only the author can read unapproved posts
          allow read: if resource.data.approved == true || request.auth.uid == resource.data.author


          And then query for only approved posts with:



          db.collection("posts").where("approved", "==", true).get()


          In this last example, the security rules can validate that the query only requests posts that they have access to, so it allows the query.



          For more on this, see:



          • The Firestore documentation on securing queries

          • The video series Getting to know Cloud Firestore, specifically the [episode on security rules](Getting to know Cloud Firestore)





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322977%2fhow-can-i-compare-2-record-for-permission-firestore-rule%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It depends on how you're trying to read from the collection.



            If you're trying to read a specific document (e.g. /posts/post123) that is not from a banned user, the read should work. And if you're trying to read a specific document from a banned user, the read should be rejected.



            If you're trying to read the entire /posts collection, that will indeed fail with the above security rules. The reason for that is that security rules don't filter your data; they merely ensure that the read operation only tries to read data that it's authorized for. And reading all of /posts is not authorized, since there are certain documents that are not readable.



            To read all posts from unbanned users, you'll need to attach a listener that only tried to read those documents. In pseudo-code that would be something like:



            db.collection('posts').where('user', 'not in', '/bannedusers')


            But this unfortunately isn't possible in Firestore since it'd require a server-side join, which would make it impossible for Firestore to meet its performance guarantees.



            But say for example that you have an approval flow, where each post needs to be approved before it can be read by other users. In that case you could enforce this in your security rules with:



            // anyone can read approved posts, but only the author can read unapproved posts
            allow read: if resource.data.approved == true || request.auth.uid == resource.data.author


            And then query for only approved posts with:



            db.collection("posts").where("approved", "==", true).get()


            In this last example, the security rules can validate that the query only requests posts that they have access to, so it allows the query.



            For more on this, see:



            • The Firestore documentation on securing queries

            • The video series Getting to know Cloud Firestore, specifically the [episode on security rules](Getting to know Cloud Firestore)





            share|improve this answer



























              0














              It depends on how you're trying to read from the collection.



              If you're trying to read a specific document (e.g. /posts/post123) that is not from a banned user, the read should work. And if you're trying to read a specific document from a banned user, the read should be rejected.



              If you're trying to read the entire /posts collection, that will indeed fail with the above security rules. The reason for that is that security rules don't filter your data; they merely ensure that the read operation only tries to read data that it's authorized for. And reading all of /posts is not authorized, since there are certain documents that are not readable.



              To read all posts from unbanned users, you'll need to attach a listener that only tried to read those documents. In pseudo-code that would be something like:



              db.collection('posts').where('user', 'not in', '/bannedusers')


              But this unfortunately isn't possible in Firestore since it'd require a server-side join, which would make it impossible for Firestore to meet its performance guarantees.



              But say for example that you have an approval flow, where each post needs to be approved before it can be read by other users. In that case you could enforce this in your security rules with:



              // anyone can read approved posts, but only the author can read unapproved posts
              allow read: if resource.data.approved == true || request.auth.uid == resource.data.author


              And then query for only approved posts with:



              db.collection("posts").where("approved", "==", true).get()


              In this last example, the security rules can validate that the query only requests posts that they have access to, so it allows the query.



              For more on this, see:



              • The Firestore documentation on securing queries

              • The video series Getting to know Cloud Firestore, specifically the [episode on security rules](Getting to know Cloud Firestore)





              share|improve this answer

























                0












                0








                0







                It depends on how you're trying to read from the collection.



                If you're trying to read a specific document (e.g. /posts/post123) that is not from a banned user, the read should work. And if you're trying to read a specific document from a banned user, the read should be rejected.



                If you're trying to read the entire /posts collection, that will indeed fail with the above security rules. The reason for that is that security rules don't filter your data; they merely ensure that the read operation only tries to read data that it's authorized for. And reading all of /posts is not authorized, since there are certain documents that are not readable.



                To read all posts from unbanned users, you'll need to attach a listener that only tried to read those documents. In pseudo-code that would be something like:



                db.collection('posts').where('user', 'not in', '/bannedusers')


                But this unfortunately isn't possible in Firestore since it'd require a server-side join, which would make it impossible for Firestore to meet its performance guarantees.



                But say for example that you have an approval flow, where each post needs to be approved before it can be read by other users. In that case you could enforce this in your security rules with:



                // anyone can read approved posts, but only the author can read unapproved posts
                allow read: if resource.data.approved == true || request.auth.uid == resource.data.author


                And then query for only approved posts with:



                db.collection("posts").where("approved", "==", true).get()


                In this last example, the security rules can validate that the query only requests posts that they have access to, so it allows the query.



                For more on this, see:



                • The Firestore documentation on securing queries

                • The video series Getting to know Cloud Firestore, specifically the [episode on security rules](Getting to know Cloud Firestore)





                share|improve this answer













                It depends on how you're trying to read from the collection.



                If you're trying to read a specific document (e.g. /posts/post123) that is not from a banned user, the read should work. And if you're trying to read a specific document from a banned user, the read should be rejected.



                If you're trying to read the entire /posts collection, that will indeed fail with the above security rules. The reason for that is that security rules don't filter your data; they merely ensure that the read operation only tries to read data that it's authorized for. And reading all of /posts is not authorized, since there are certain documents that are not readable.



                To read all posts from unbanned users, you'll need to attach a listener that only tried to read those documents. In pseudo-code that would be something like:



                db.collection('posts').where('user', 'not in', '/bannedusers')


                But this unfortunately isn't possible in Firestore since it'd require a server-side join, which would make it impossible for Firestore to meet its performance guarantees.



                But say for example that you have an approval flow, where each post needs to be approved before it can be read by other users. In that case you could enforce this in your security rules with:



                // anyone can read approved posts, but only the author can read unapproved posts
                allow read: if resource.data.approved == true || request.auth.uid == resource.data.author


                And then query for only approved posts with:



                db.collection("posts").where("approved", "==", true).get()


                In this last example, the security rules can validate that the query only requests posts that they have access to, so it allows the query.



                For more on this, see:



                • The Firestore documentation on securing queries

                • The video series Getting to know Cloud Firestore, specifically the [episode on security rules](Getting to know Cloud Firestore)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 14:46









                Frank van PuffelenFrank van Puffelen

                255k32410436




                255k32410436





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322977%2fhow-can-i-compare-2-record-for-permission-firestore-rule%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현