这是一个实验性的协议插件,它基于 Google 的协议缓冲格式生成用于 Cloud Firestore 的 Firebase 规则。这使您可以轻松验证和验证数据。
这是一个实验性的协议插件,它基于 Google 的协议缓冲格式生成用于 Cloud Firestore 的 Firebase 规则。这使您可以轻松验证和验证数据。
This is an experimental plugin for Security Rules, which means you should always validate these by hand before you decide to deploy these to a production environment.
This repository is maintained by Googlers but is not a supported Firebase product. Issues here are answered by maintainers and other community members on GitHub on a best-effort basis.
This is an experimental protoc
plugin
that generates Firebase Rules for Cloud
Firestore based
on Google's Protocol Buffer
format.
This allows you to easily validate your data in a platform independent manner.
Here is a quick example:
syntax = "proto2";
package tutorial;
message Person {
required string name = 1;
optional string email = 2;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
optional string number = 1;
optional PhoneType type = 2;
}
optional PhoneNumber phone = 3;
}This plugin generates the following Firebase Rules function that can be used to validate your incoming data.
…To use this protoc plugin once you have your protocol buffers defined, follow
these steps:
protoc$PATH or use the
--plugin=protoc-gen-firebase_rules=./path/to/protoc-gen-firebase_rules
optionprotoc tool using the --firebase_rules_out=./directory flag
to output your firestore.rules file with generated functions"firebase_rules_options.proto" like the below example
the --proto_path=./directory flag will need to be added to include the
directory of the firebase_rules_options.proto file along with the protobuf
files from the src directory of the Google Protobuf
repo. An more indepth
discussion of this can be found in this
issue.If you run into trouble feel free to check out our
example_usage.sh
script or file an issue
…This would generate the following functions.
…Install Bazel.
Build with bazel build //...
A sample invocation of the plugin, protoc-gen-firebase_rules, is available
in example_usage.sh. This script can be run from the command line.
It's easy to use protobuf_rules_gen if your project already uses Bazel.
proto_gen_firebase_rules_commit = "TODO"
http_archive(
name = "proto_gen_firebase_rules",
sha256 = "TODO",
strip_prefix = "protobuf-rules-gen-" + proto_gen_firebase_rules_commit,
url = "http://github.com/FirebaseExtended/protobuf-rules-gen/archive/" + proto_gen_firebase_rules_commit + ".tar.gz",
)
load("@proto_gen_firebase_rules//bazel:repositories.bzl", "protobuf_rules_gen_repositories")
protobuf_rules_gen_repositories()load("@proto_gen_firebase_rules//bazel:defs.bzl", "firestore_rules_proto_library", "firestore_rules_binary")There are three rules available:
See example/BUILD for an example of how to use these rules.
Build the proto-gen-firebase_rules binary via bazel build //...
Ensure all the tests pass via bazel test //...
Build a binary for each platform (windows, linux, and darwin).
Tag a GitHub release and attach each prebuilt binary to the release.
protobuf-rules-gen was initiated with ❤️️ by Tyler
Rockwood.
This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
暂无开放 Issues,或尚未同步最近议题。