这是indexloc提供的服务,不要输入任何密码
Skip to content

database.rules.json is not applied to the default RTDB instance in the emulator. #3124

@aameen951

Description

@aameen951

Hi there,

This #2979 pull request fixed one part of the problem mentioned in #2965 where the default instance in hosting is different from the default instance in firebase-admin and both of them now reference the same instance which is project-id-default-rtdb.

However, the rules in database.rule.json are still being applied to project-id instead of project-id-default-rtdb, and I don't know how to change that manually.

[REQUIRED] Environment info

firebase-tools: 9.3.0
Platform: Windows

[REQUIRED] Test case

functions/index.js

const admin = require("firebase-admin");

// After #2979, The following line will uses `http://localhost:9000?ns=project-id-default-rtdb`
admin.initializeApp();

admin.database().ref('test').set(1);

database.rules.json

{
  "rules": {
    "test":{
      ".read": true
    },
    ".read": false,
    ".write": false
  }
}

[REQUIRED] Steps to reproduce

  1. Run the command: curl localhost:9000/.settings/rules.json?ns=project-id-default-rtdb -H "Authorization: Bearer owner"
  2. The output is:
{
    "rules": {
        ".read": true,
        ".write": true
    }
}
  1. Run the command: curl localhost:9000/.settings/rules.json?ns=project-id -H "Authorization: Bearer owner"
  2. The output is:
{
  "rules": {
    "test":{
      ".read": true
    },
    ".read": false,
    ".write": false
  }
}

[REQUIRED] Expected behavior

Since project-id-default-rtdb is now the default instance, the database.rules.json should also be applied to project-id-default-rtdb instance instead of project-id instance.

[REQUIRED] Actual behavior

Now, database.rules.json is applied to project-id.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions