增加商业版认证校验API

This commit is contained in:
刘祥超
2021-09-16 10:34:00 +08:00
parent 1392dce1c5
commit 728061c66c
2 changed files with 226 additions and 31 deletions

View File

@@ -242,6 +242,109 @@ func (*ResetAuthorityKeyRequest) Descriptor() ([]byte, []int) {
return file_service_authority_key_proto_rawDescGZIP(), []int{3}
}
// 校验Key
type ValidateAuthorityKeyRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
func (x *ValidateAuthorityKeyRequest) Reset() {
*x = ValidateAuthorityKeyRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_authority_key_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ValidateAuthorityKeyRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateAuthorityKeyRequest) ProtoMessage() {}
func (x *ValidateAuthorityKeyRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_authority_key_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateAuthorityKeyRequest.ProtoReflect.Descriptor instead.
func (*ValidateAuthorityKeyRequest) Descriptor() ([]byte, []int) {
return file_service_authority_key_proto_rawDescGZIP(), []int{4}
}
func (x *ValidateAuthorityKeyRequest) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
type ValidateAuthorityKeyResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
}
func (x *ValidateAuthorityKeyResponse) Reset() {
*x = ValidateAuthorityKeyResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_service_authority_key_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ValidateAuthorityKeyResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateAuthorityKeyResponse) ProtoMessage() {}
func (x *ValidateAuthorityKeyResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_authority_key_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateAuthorityKeyResponse.ProtoReflect.Descriptor instead.
func (*ValidateAuthorityKeyResponse) Descriptor() ([]byte, []int) {
return file_service_authority_key_proto_rawDescGZIP(), []int{5}
}
func (x *ValidateAuthorityKeyResponse) GetIsOk() bool {
if x != nil {
return x.IsOk
}
return false
}
func (x *ValidateAuthorityKeyResponse) GetError() string {
if x != nil {
return x.Error
}
return ""
}
var File_service_authority_key_proto protoreflect.FileDescriptor
var file_service_authority_key_proto_rawDesc = []byte{
@@ -271,23 +374,36 @@ var file_service_authority_key_proto_rawDesc = []byte{
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x0c, 0x61, 0x75, 0x74,
0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x22, 0x1a, 0x0a, 0x18, 0x52, 0x65, 0x73,
0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0xec, 0x01, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a,
0x12, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79,
0x4b, 0x65, 0x79, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41,
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x12, 0x4d, 0x0a, 0x10, 0x72, 0x65, 0x61, 0x64, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x61, 0x64,
0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x41, 0x75, 0x74,
0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x41, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x65,
0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63,
0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2f, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x48, 0x0a, 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61,
0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x32, 0xc7, 0x02, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65,
0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x12, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x1d,
0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x4d, 0x0a,
0x10, 0x72, 0x65, 0x61, 0x64, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65,
0x79, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x41, 0x75, 0x74, 0x68, 0x6f,
0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74,
0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x11,
0x72, 0x65, 0x73, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65,
0x79, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68,
0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12,
0x59, 0x0a, 0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f,
0x72, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61, 0x6c,
0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b, 0x65,
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61,
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x4b,
0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -302,25 +418,29 @@ func file_service_authority_key_proto_rawDescGZIP() []byte {
return file_service_authority_key_proto_rawDescData
}
var file_service_authority_key_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_service_authority_key_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_service_authority_key_proto_goTypes = []interface{}{
(*UpdateAuthorityKeyRequest)(nil), // 0: pb.UpdateAuthorityKeyRequest
(*ReadAuthorityKeyRequest)(nil), // 1: pb.ReadAuthorityKeyRequest
(*ReadAuthorityKeyResponse)(nil), // 2: pb.ReadAuthorityKeyResponse
(*ResetAuthorityKeyRequest)(nil), // 3: pb.ResetAuthorityKeyRequest
(*AuthorityKey)(nil), // 4: pb.AuthorityKey
(*RPCSuccess)(nil), // 5: pb.RPCSuccess
(*UpdateAuthorityKeyRequest)(nil), // 0: pb.UpdateAuthorityKeyRequest
(*ReadAuthorityKeyRequest)(nil), // 1: pb.ReadAuthorityKeyRequest
(*ReadAuthorityKeyResponse)(nil), // 2: pb.ReadAuthorityKeyResponse
(*ResetAuthorityKeyRequest)(nil), // 3: pb.ResetAuthorityKeyRequest
(*ValidateAuthorityKeyRequest)(nil), // 4: pb.ValidateAuthorityKeyRequest
(*ValidateAuthorityKeyResponse)(nil), // 5: pb.ValidateAuthorityKeyResponse
(*AuthorityKey)(nil), // 6: pb.AuthorityKey
(*RPCSuccess)(nil), // 7: pb.RPCSuccess
}
var file_service_authority_key_proto_depIdxs = []int32{
4, // 0: pb.ReadAuthorityKeyResponse.authorityKey:type_name -> pb.AuthorityKey
6, // 0: pb.ReadAuthorityKeyResponse.authorityKey:type_name -> pb.AuthorityKey
0, // 1: pb.AuthorityKeyService.updateAuthorityKey:input_type -> pb.UpdateAuthorityKeyRequest
1, // 2: pb.AuthorityKeyService.readAuthorityKey:input_type -> pb.ReadAuthorityKeyRequest
3, // 3: pb.AuthorityKeyService.resetAuthorityKey:input_type -> pb.ResetAuthorityKeyRequest
5, // 4: pb.AuthorityKeyService.updateAuthorityKey:output_type -> pb.RPCSuccess
2, // 5: pb.AuthorityKeyService.readAuthorityKey:output_type -> pb.ReadAuthorityKeyResponse
5, // 6: pb.AuthorityKeyService.resetAuthorityKey:output_type -> pb.RPCSuccess
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
4, // 4: pb.AuthorityKeyService.validateAuthorityKey:input_type -> pb.ValidateAuthorityKeyRequest
7, // 5: pb.AuthorityKeyService.updateAuthorityKey:output_type -> pb.RPCSuccess
2, // 6: pb.AuthorityKeyService.readAuthorityKey:output_type -> pb.ReadAuthorityKeyResponse
7, // 7: pb.AuthorityKeyService.resetAuthorityKey:output_type -> pb.RPCSuccess
5, // 8: pb.AuthorityKeyService.validateAuthorityKey:output_type -> pb.ValidateAuthorityKeyResponse
5, // [5:9] is the sub-list for method output_type
1, // [1:5] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
@@ -382,6 +502,30 @@ func file_service_authority_key_proto_init() {
return nil
}
}
file_service_authority_key_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ValidateAuthorityKeyRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_authority_key_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ValidateAuthorityKeyResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -389,7 +533,7 @@ func file_service_authority_key_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_authority_key_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
@@ -421,6 +565,8 @@ type AuthorityKeyServiceClient interface {
ReadAuthorityKey(ctx context.Context, in *ReadAuthorityKeyRequest, opts ...grpc.CallOption) (*ReadAuthorityKeyResponse, error)
// 重置Key
ResetAuthorityKey(ctx context.Context, in *ResetAuthorityKeyRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
// 校验Key
ValidateAuthorityKey(ctx context.Context, in *ValidateAuthorityKeyRequest, opts ...grpc.CallOption) (*ValidateAuthorityKeyResponse, error)
}
type authorityKeyServiceClient struct {
@@ -458,6 +604,15 @@ func (c *authorityKeyServiceClient) ResetAuthorityKey(ctx context.Context, in *R
return out, nil
}
func (c *authorityKeyServiceClient) ValidateAuthorityKey(ctx context.Context, in *ValidateAuthorityKeyRequest, opts ...grpc.CallOption) (*ValidateAuthorityKeyResponse, error) {
out := new(ValidateAuthorityKeyResponse)
err := c.cc.Invoke(ctx, "/pb.AuthorityKeyService/validateAuthorityKey", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthorityKeyServiceServer is the server API for AuthorityKeyService service.
type AuthorityKeyServiceServer interface {
// 设置Key
@@ -466,6 +621,8 @@ type AuthorityKeyServiceServer interface {
ReadAuthorityKey(context.Context, *ReadAuthorityKeyRequest) (*ReadAuthorityKeyResponse, error)
// 重置Key
ResetAuthorityKey(context.Context, *ResetAuthorityKeyRequest) (*RPCSuccess, error)
// 校验Key
ValidateAuthorityKey(context.Context, *ValidateAuthorityKeyRequest) (*ValidateAuthorityKeyResponse, error)
}
// UnimplementedAuthorityKeyServiceServer can be embedded to have forward compatible implementations.
@@ -481,6 +638,9 @@ func (*UnimplementedAuthorityKeyServiceServer) ReadAuthorityKey(context.Context,
func (*UnimplementedAuthorityKeyServiceServer) ResetAuthorityKey(context.Context, *ResetAuthorityKeyRequest) (*RPCSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method ResetAuthorityKey not implemented")
}
func (*UnimplementedAuthorityKeyServiceServer) ValidateAuthorityKey(context.Context, *ValidateAuthorityKeyRequest) (*ValidateAuthorityKeyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ValidateAuthorityKey not implemented")
}
func RegisterAuthorityKeyServiceServer(s *grpc.Server, srv AuthorityKeyServiceServer) {
s.RegisterService(&_AuthorityKeyService_serviceDesc, srv)
@@ -540,6 +700,24 @@ func _AuthorityKeyService_ResetAuthorityKey_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _AuthorityKeyService_ValidateAuthorityKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ValidateAuthorityKeyRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthorityKeyServiceServer).ValidateAuthorityKey(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.AuthorityKeyService/ValidateAuthorityKey",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthorityKeyServiceServer).ValidateAuthorityKey(ctx, req.(*ValidateAuthorityKeyRequest))
}
return interceptor(ctx, in, info, handler)
}
var _AuthorityKeyService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.AuthorityKeyService",
HandlerType: (*AuthorityKeyServiceServer)(nil),
@@ -556,6 +734,10 @@ var _AuthorityKeyService_serviceDesc = grpc.ServiceDesc{
MethodName: "resetAuthorityKey",
Handler: _AuthorityKeyService_ResetAuthorityKey_Handler,
},
{
MethodName: "validateAuthorityKey",
Handler: _AuthorityKeyService_ValidateAuthorityKey_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_authority_key.proto",

View File

@@ -16,6 +16,9 @@ service AuthorityKeyService {
// 重置Key
rpc resetAuthorityKey (ResetAuthorityKeyRequest) returns (RPCSuccess);
// 校验Key
rpc validateAuthorityKey(ValidateAuthorityKeyRequest) returns (ValidateAuthorityKeyResponse);
}
// 设置Key
@@ -40,4 +43,14 @@ message ReadAuthorityKeyResponse {
// 重置Key
message ResetAuthorityKeyRequest {
}
// 校验Key
message ValidateAuthorityKeyRequest {
string key = 1;
}
message ValidateAuthorityKeyResponse {
bool isOk = 1;
string error = 2;
}