I have a collection with 1 million records split across 20 organisations which is named people.
I am wanting to configure a mobile application to display the people data the logged in user has permission to. I set up the authentication for the mobile app to “Custom JWT” authentication and setup a claim in the JWT for organisationId. Within Atlas I then use the metadata fields to map the claim to a field.
I now want to setup a rule which will only return the people data for the organisation the user has access to so all permissions are configured on the server side. A concern is that if I set up the query on the app side and someone manages to decompile my app that they could generate a JWT and view any data for any organisation.
I thought the following under the people rules for read access is what I would want but this returns me 0 records (even though there should be about 40k being returned)
And just to confirm, are you doing this in the document permissions? If this does not work, feel free to send a link to your App Services URL and I can take a look.
This didn’t impact anything I still view no information on my local application.
Is there something that should be in the “apply when” area? I did attempt to put this filter in there and then the client application crashed and there was an error log which returned the following:
no applicable role found, denying all access for tables: [“Person”] (ProtocolErrorCode=201)
I’ve already proven off that if the claim doesn’t exist in the JWT that the code throws an exception as expected. I am not sure though on how to see what the values of the claims are for the data mapping. Is there somewhere I can check this within Atlas as I also can’t appear to view this as part of the user object in my .net code.
I’d like to thank you for all your assistance. I have managed to get it working but I’m not sure exactly which bit fixed the problem. I already had collection level queryable fields which I did change to global queryable fields (although I’m still struggling to understand why you would have collection level if only global works).
I’m now going to work backwards to try and understand the changes implemented that got me to that point.
I am glad that this resolved your issues. Collection-Level only applies to the individual collections that they are defined for, so if you had 3 collections and you only defined OrganizationId as a collection queryable field for one of them, then if the rule was referencing a different collection (or if it was a default rule and thus applied to all other collections) then it would not be the case that OrganizationId was queryable on all collections.
Hope that makes sense and happy to answer any other questions.