Simulation Rules - access allowed; Android - acces

2019-08-17 14:16发布

I have a rule which executes correctly in Firestore Rules simulation as seen below.

Simulation

The /config/permissions document is many arrays named X153, X154, X155, etc., which contain UIDs:

config/permissions

When I attempt this access in Android, I get a PERMISSION_DENIED response.

Code:

DocumentReference docRef = db.collection("arcs").document("X153");
        docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
            @Override
            public void onComplete(@NonNull Task<DocumentSnapshot> task) {
                if (task.isSuccessful()) {
                    DocumentSnapshot document = task.getResult();
                    if (document.exists()) {
                        Log.d("FIREBASE", "DocumentSnapshot data: " + document.getData());
                    } else {
                        Log.d("FIREBASE", "No such document");
                    }
                } else {
                    Log.d("FIREBASE", "get failed with ", task.getException());
                }
            }
        });

The UID used in simulation is the same as in Android:

firebaseauth

If I set the rule to authenticate access of the UID directly

  • Android permission accepted, returns document.

If I flatten out the config/permissions structure to just key/values, like X153 : '9iXQBaG3Ycaey4cFUj8tZjhKMaB3', and change the rule to

match /arcs/{x} {
    allow read: if request.auth.uid == get(/config/permissions).data[x];
}
  • Android returns PERMISSION DENIED.

Why am I receiving this PERMISSION DENIED response using the rule pictured?

0条回答
登录 后发表回答