This release is a pre-release and may not be stable for production use.
python grpc validator
plugin of validate request field for python grpc server.
- TODO:
type hint for different field type.(such as only string field can do a string length check.)
test case & Makefile.
a cli to help protoc with validator.proto.
anymore bugs or improves?
How To
install
pip install grpc-proto-validator
2. copy validator.proto to your project proto path and do protoc.(TODO a cli help to copy or build proto.)
The validator.proto is included in this package, you can find it in python site-packages path.
A example on how to generate the grpc files:
$ python -m grpc_tools.protoc \
--proto_path={/path/to/validator/proto} \
--proto_path={/path/to/your/project/proto} \
--python_out={/path/to/project/src} \
--grpc_python_out={/path/to/project/src} \
path/to/your.proto
change your service and *_pb2 code.
To avoid protobuf import error, change one line in the generated python file(like hello_bro_pb2.py).
from:
import validator_pb2 as validator__pb2
to:
import grpc_proto_validator.validator_pb2 as validator__pb2.
Then create service with validator:
import six
from grpc_validator.validator import ValidateMetaclass
class YourService(six.with_metaclass(ValidateMetaclass,
YourService_pb2_grpc.YourServiceServer)):
def behaviour1(self, request, context)
...
Also, you can select individual service handler to do the field check:
from grpc_validator.validator import validator_wrap
class YourService(YourService_pb2_grpc.YourServiceServer):
def behaviour(self, request, context):
"""request will not be validated."""
...
@validator_wrap
def behaviour2(self, request, context):
...
Notice
Someone has used go-proto-validator before will notice that I almost reuse its proto file which make it easier to co-work with our golang service team.
But please don’t mix these two proto files. !!!THEY ARE NOT IN COMMON USE!!!
Any help or idea is favourably receive. Please just make a issue.
LICENSE
MIT.
Metadata
Release files for grpc-proto-validator 0.1.2.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grpc-proto-validator-0.1.2.dev0.tar.gz | 9.5 kB | Without provenance | Details for grpc-proto-validator-0.1.2.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grpc_proto_validator-0.1.2.dev0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for grpc_proto_validator-0.1.2.dev0-py2.py3-none-any.whl |
Total release size: 17.3 kB
Release files / grpc-proto-validator-0.1.2.dev0.tar.gz
| Download URL | grpc-proto-validator-0.1.2.dev0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
735cab0de7f4f3cf9a27c5ac371ac865baed141ed303159d54a0cc1a430271a5
|
|
BLAKE2b-256 checksum How to use checksums |
7a48317ff82b44d6a6ed97a9cae42f562ad1d091e821f81f28ec34d32921f172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Release files / grpc_proto_validator-0.1.2.dev0-py2.py3-none-any.whl
| Download URL | grpc_proto_validator-0.1.2.dev0-py2.py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bcfcc8f7edaf1077e926a4a97242f5e91c2b8af7ab6e8e4c3f491529ce29644d
|
|
BLAKE2b-256 checksum How to use checksums |
3b58dd770d423655a6a8bdb60e3ce20cebca6f2586013b1de97d9835b86dad43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Security for grpc-proto-validator 0.1.2.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.