-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add StorageRulesManagerRegistry to handle rules files for multiple targets #4281
Add StorageRulesManagerRegistry to handle rules files for multiple targets #4281
Conversation
40af2f8
to
aa0ebeb
Compare
789252a
to
4b45374
Compare
src/emulator/storage/index.ts
Outdated
return this._rulesManager.getRuleset(resource); | ||
} | ||
|
||
async setRules(rules: RulesType, resource: string): Promise<StorageRulesIssues> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a pattern of accessing StorageEmulator internals from within server.ts
so I'm not sure we need to wrap the rules manager's interface here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can expose the rules manager instead for the sake of consistency. Curious, is there any benefit to exposing the internals?
0f00d1a
to
9ab16db
Compare
9ab16db
to
015a865
Compare
8e24f4c
to
4575d14
Compare
4575d14
to
9eaf5c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript LGTM
@@ -0,0 +1 @@ | |||
- Adds support for configuration with multiple storage targets (#4281). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should coordinate with @puf to get the public docs updated once this is released :) https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some docs, somewhat hidden away...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, the emulator-specific docs don't seem to mention this: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration
But it's okay that we don't reiterate everything since it's already in the CLI documentation
* Updates the source file and, correspondingly, the file watcher and ruleset for the resource. | ||
* Returns an array of errors and/or warnings that arise from loading the ruleset. | ||
*/ | ||
updateSourceFile(rules: SourceFile, resource: string): Promise<StorageRulesIssues>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline, we may want to remove this method as we don't need to support modifying currently running StorageRulesManagers
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, will do in follow up PR.
bce98a8
to
4f53ed4
Compare
4f53ed4
to
0c8c165
Compare
@@ -0,0 +1 @@ | |||
- Adds support for configuration with multiple storage targets (#4281). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, the emulator-specific docs don't seem to mention this: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration
But it's okay that we don't reiterate everything since it's already in the CLI documentation
Description
Fixes #3390. Following up to #4263, this PR adds a
StorageRulesManager
that will live inside the Storage Emulator. The interface is implemented by:StorageRulesManagerImplementation
, which keeps track of rules for a single resourceStorageRulesManagerRegistry
, which maps resource toStorageRulesManagerImplementation
In the server, all calls to the validator will pass along the
resource
aka bucket id in order to determine which ruleset to use.