Payload Validator
In complex network environments, hardware failures or malicious data tampering may lead to inconsistencies between the data sent and received. In certain scenarios, users need the ability to identify potential data tampering in RPC requests or responses.
Kitex now supports payload validation, which can effectively detect and prevent such issues. Additionally, the framework allows for the extension of custom verification logic, providing a flexible integration approach to meet diverse security needs.
Note:
- Kitex version >= v0.11.0
- Transport protocol uses ttheader(refer to the doc for configuration Transport Protocol)
- Payload protocol uses Thrift(Generic call, gRPC, etc. are not supported now)
- The generated checksum length is limited to 4KB (exceeding this limit will directly return an error).
Configuration
CRC32 Check
Both client and server use the WithCodec
option to configure the codec with crc32 check.
client side
server side
Demo:https://github.com/cloudwego/kitex-tests/blob/main/thriftrpc/normalcall/normalcall_test.go#L523
Customize your validator
This feature allows users to extend their own validators by implementing the following interface
use codec.CodecConfig
to configure
Please refer to the following examples (for testing reference only, do not use directly).