author | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-04-04 15:03:15 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-04-04 15:03:15 UTC |
parent | 5a14783c8cdd509a4cd986bfede3b255a7f254b0 |
internal/client/grpc.go | +10 | -2 |
internal/proto/remoteu2f.pb.go | +214 | -74 |
remoteu2f-proxy/server.go | +1 | -1 |
diff --git a/internal/client/grpc.go b/internal/client/grpc.go index ea0ad90..b0e5fc8 100644 --- a/internal/client/grpc.go +++ b/internal/client/grpc.go @@ -83,7 +83,11 @@ func (c *RemoteU2FClient) PrepareRegister( ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() - key, err := c.c.PrepareOp(ctx, &pb.Prepare{j, msg, pb.Prepare_REGISTER}) + key, err := c.c.PrepareOp(ctx, &pb.Prepare{ + Json: j, + Msg: msg, + Rtype: pb.Prepare_REGISTER, + }) if err != nil { return nil, fmt.Errorf("error preparing: %v", err) } @@ -149,7 +153,11 @@ func (c *RemoteU2FClient) PrepareAuthentication( defer cancel() key, err := c.c.PrepareOp( - ctx, &pb.Prepare{j, msg, pb.Prepare_AUTHENTICATE}) + ctx, &pb.Prepare{ + Json: j, + Msg: msg, + Rtype: pb.Prepare_AUTHENTICATE, + }) if err != nil { return nil, fmt.Errorf("error preparing: %v", err) } diff --git a/internal/proto/remoteu2f.pb.go b/internal/proto/remoteu2f.pb.go index e34fd6d..58abfd4 100644 --- a/internal/proto/remoteu2f.pb.go +++ b/internal/proto/remoteu2f.pb.go @@ -1,28 +1,16 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: remoteu2f.proto -// DO NOT EDIT! -/* -Package remoteu2f is a generated protocol buffer package. - -It is generated from these files: - remoteu2f.proto - -It has these top-level messages: - Void - Url - Prepare - Response -*/ package remoteu2f -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - import ( - context "golang.org/x/net/context" + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -34,7 +22,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Request type, used only for selecting the web page template (no // functional behaviour difference from an RPC perspective). @@ -51,6 +39,7 @@ var Prepare_RType_name = map[int32]string{ 1: "REGISTER", 2: "AUTHENTICATE", } + var Prepare_RType_value = map[string]int32{ "UNKNOWN": 0, "REGISTER": 1, @@ -60,27 +49,90 @@ var Prepare_RType_value = map[string]int32{ func (x Prepare_RType) String() string { return proto.EnumName(Prepare_RType_name, int32(x)) } -func (Prepare_RType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } + +func (Prepare_RType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b29fab4d651f9bdd, []int{2, 0} +} // Generic empty message, for RPCs that don't need one. type Void struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Void) Reset() { *m = Void{} } +func (m *Void) String() string { return proto.CompactTextString(m) } +func (*Void) ProtoMessage() {} +func (*Void) Descriptor() ([]byte, []int) { + return fileDescriptor_b29fab4d651f9bdd, []int{0} +} + +func (m *Void) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Void.Unmarshal(m, b) +} +func (m *Void) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Void.Marshal(b, m, deterministic) +} +func (m *Void) XXX_Merge(src proto.Message) { + xxx_messageInfo_Void.Merge(m, src) +} +func (m *Void) XXX_Size() int { + return xxx_messageInfo_Void.Size(m) +} +func (m *Void) XXX_DiscardUnknown() { + xxx_messageInfo_Void.DiscardUnknown(m) } -func (m *Void) Reset() { *m = Void{} } -func (m *Void) String() string { return proto.CompactTextString(m) } -func (*Void) ProtoMessage() {} -func (*Void) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_Void proto.InternalMessageInfo // Generic message containing a request key and URL. type Url struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Url) Reset() { *m = Url{} } -func (m *Url) String() string { return proto.CompactTextString(m) } -func (*Url) ProtoMessage() {} -func (*Url) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +func (m *Url) Reset() { *m = Url{} } +func (m *Url) String() string { return proto.CompactTextString(m) } +func (*Url) ProtoMessage() {} +func (*Url) Descriptor() ([]byte, []int) { + return fileDescriptor_b29fab4d651f9bdd, []int{1} +} + +func (m *Url) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Url.Unmarshal(m, b) +} +func (m *Url) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Url.Marshal(b, m, deterministic) +} +func (m *Url) XXX_Merge(src proto.Message) { + xxx_messageInfo_Url.Merge(m, src) +} +func (m *Url) XXX_Size() int { + return xxx_messageInfo_Url.Size(m) +} +func (m *Url) XXX_DiscardUnknown() { + xxx_messageInfo_Url.DiscardUnknown(m) +} + +var xxx_messageInfo_Url proto.InternalMessageInfo + +func (m *Url) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Url) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} // Prepare an operation. type Prepare struct { @@ -91,31 +143,129 @@ type Prepare struct { // opaque and decode it again at javascript. Json []byte `protobuf:"bytes,1,opt,name=json,proto3" json:"json,omitempty"` // User-readable message to show on the web page. - Msg string `protobuf:"bytes,2,opt,name=msg" json:"msg,omitempty"` - Rtype Prepare_RType `protobuf:"varint,3,opt,name=rtype,enum=remoteu2f.Prepare_RType" json:"rtype,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` + Rtype Prepare_RType `protobuf:"varint,3,opt,name=rtype,proto3,enum=remoteu2f.Prepare_RType" json:"rtype,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Prepare) Reset() { *m = Prepare{} } -func (m *Prepare) String() string { return proto.CompactTextString(m) } -func (*Prepare) ProtoMessage() {} -func (*Prepare) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (m *Prepare) Reset() { *m = Prepare{} } +func (m *Prepare) String() string { return proto.CompactTextString(m) } +func (*Prepare) ProtoMessage() {} +func (*Prepare) Descriptor() ([]byte, []int) { + return fileDescriptor_b29fab4d651f9bdd, []int{2} +} + +func (m *Prepare) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Prepare.Unmarshal(m, b) +} +func (m *Prepare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Prepare.Marshal(b, m, deterministic) +} +func (m *Prepare) XXX_Merge(src proto.Message) { + xxx_messageInfo_Prepare.Merge(m, src) +} +func (m *Prepare) XXX_Size() int { + return xxx_messageInfo_Prepare.Size(m) +} +func (m *Prepare) XXX_DiscardUnknown() { + xxx_messageInfo_Prepare.DiscardUnknown(m) +} + +var xxx_messageInfo_Prepare proto.InternalMessageInfo + +func (m *Prepare) GetJson() []byte { + if m != nil { + return m.Json + } + return nil +} + +func (m *Prepare) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +func (m *Prepare) GetRtype() Prepare_RType { + if m != nil { + return m.Rtype + } + return Prepare_UNKNOWN +} // Operation response. type Response struct { - Json []byte `protobuf:"bytes,1,opt,name=json,proto3" json:"json,omitempty"` + Json []byte `protobuf:"bytes,1,opt,name=json,proto3" json:"json,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_b29fab4d651f9bdd, []int{3} +} + +func (m *Response) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Response.Unmarshal(m, b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return xxx_messageInfo_Response.Size(m) +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetJson() []byte { + if m != nil { + return m.Json + } + return nil +} func init() { + proto.RegisterEnum("remoteu2f.Prepare_RType", Prepare_RType_name, Prepare_RType_value) proto.RegisterType((*Void)(nil), "remoteu2f.Void") proto.RegisterType((*Url)(nil), "remoteu2f.Url") proto.RegisterType((*Prepare)(nil), "remoteu2f.Prepare") proto.RegisterType((*Response)(nil), "remoteu2f.Response") - proto.RegisterEnum("remoteu2f.Prepare_RType", Prepare_RType_name, Prepare_RType_value) +} + +func init() { proto.RegisterFile("remoteu2f.proto", fileDescriptor_b29fab4d651f9bdd) } + +var fileDescriptor_b29fab4d651f9bdd = []byte{ + // 285 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x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xa8, 0x45, 0xd0, 0x02, + 0xd3, 0xcf, 0xd2, 0x9b, 0x20, 0x4e, 0xa3, 0x4b, 0x3f, 0x0d, 0xac, 0x81, 0x73, 0x02, 0x3a, 0x65, + 0xa5, 0xe0, 0x9b, 0xf2, 0xdf, 0x5e, 0xde, 0x17, 0x01, 0x83, 0x2a, 0x70, 0xe6, 0x5d, 0xe3, 0x39, + 0x18, 0x3b, 0x76, 0x22, 0x10, 0xff, 0x36, 0x9a, 0x4f, 0x7b, 0x5a, 0x7b, 0x9a, 0x15, 0x1c, 0x85, + 0xac, 0x4a, 0x44, 0xc7, 0xd8, 0x33, 0xcc, 0x8f, 0x7b, 0x7b, 0x67, 0x3a, 0x03, 0x3d, 0x64, 0x95, + 0x2f, 0x44, 0x74, 0x85, 0xb3, 0x9e, 0xa1, 0x3d, 0xfa, 0x3e, 0xe2, 0x79, 0xac, 0xbe, 0xe7, 0xe2, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xfa, 0x7d, 0x34, 0xb1, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -126,8 +276,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for RemoteU2F service - +// RemoteU2FClient is the client API for RemoteU2F service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type RemoteU2FClient interface { PrepareOp(ctx context.Context, in *Prepare, opts ...grpc.CallOption) (*Url, error) GetOpResponse(ctx context.Context, in *Url, opts ...grpc.CallOption) (*Response, error) @@ -144,7 +295,7 @@ func NewRemoteU2FClient(cc *grpc.ClientConn) RemoteU2FClient { func (c *remoteU2FClient) PrepareOp(ctx context.Context, in *Prepare, opts ...grpc.CallOption) (*Url, error) { out := new(Url) - err := grpc.Invoke(ctx, "/remoteu2f.RemoteU2F/PrepareOp", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/remoteu2f.RemoteU2F/PrepareOp", in, out, opts...) if err != nil { return nil, err } @@ -153,7 +304,7 @@ func (c *remoteU2FClient) PrepareOp(ctx context.Context, in *Prepare, opts ...gr func (c *remoteU2FClient) GetOpResponse(ctx context.Context, in *Url, opts ...grpc.CallOption) (*Response, error) { out := new(Response) - err := grpc.Invoke(ctx, "/remoteu2f.RemoteU2F/GetOpResponse", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/remoteu2f.RemoteU2F/GetOpResponse", in, out, opts...) if err != nil { return nil, err } @@ -162,21 +313,34 @@ func (c *remoteU2FClient) GetOpResponse(ctx context.Context, in *Url, opts ...gr func (c *remoteU2FClient) GetAppID(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Url, error) { out := new(Url) - err := grpc.Invoke(ctx, "/remoteu2f.RemoteU2F/GetAppID", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/remoteu2f.RemoteU2F/GetAppID", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for RemoteU2F service - +// RemoteU2FServer is the server API for RemoteU2F service. type RemoteU2FServer interface { PrepareOp(context.Context, *Prepare) (*Url, error) GetOpResponse(context.Context, *Url) (*Response, error) GetAppID(context.Context, *Void) (*Url, error) } +// UnimplementedRemoteU2FServer can be embedded to have forward compatible implementations. +type UnimplementedRemoteU2FServer struct { +} + +func (*UnimplementedRemoteU2FServer) PrepareOp(ctx context.Context, req *Prepare) (*Url, error) { + return nil, status.Errorf(codes.Unimplemented, "method PrepareOp not implemented") +} +func (*UnimplementedRemoteU2FServer) GetOpResponse(ctx context.Context, req *Url) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOpResponse not implemented") +} +func (*UnimplementedRemoteU2FServer) GetAppID(ctx context.Context, req *Void) (*Url, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAppID not implemented") +} + func RegisterRemoteU2FServer(s *grpc.Server, srv RemoteU2FServer) { s.RegisterService(&_RemoteU2F_serviceDesc, srv) } @@ -255,27 +419,3 @@ var _RemoteU2F_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "remoteu2f.proto", } - -func init() { proto.RegisterFile("remoteu2f.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 285 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x4f, 0x83, 0x40, - 0x10, 0xc5, 0xdd, 0xd2, 0x3f, 0x30, 0x62, 0x4b, 0xc6, 0x0b, 0xe9, 0xc1, 0x34, 0x9c, 0x6a, 0x4c, - 0x30, 0xc1, 0x7e, 0x01, 0xa2, 0x88, 0xc4, 0x04, 0xcc, 0x0a, 0x7a, 0xd6, 0xb8, 0x36, 0x2a, 0x74, - 0x37, 0x0b, 0x1c, 0xf8, 0x20, 0x9e, 0xfd, 0xaa, 0x86, 0x6d, 0x45, 0x52, 0xbd, 0xcd, 0xbc, 0xbc, - 0xb7, 0xbf, 0x97, 0x59, 0x98, 0x49, 0x56, 0xf0, 0x8a, 0xd5, 0xde, 0xab, 0x2b, 0x24, 0xaf, 0x38, - 0x1a, 0x9d, 0xe0, 0x8c, 0x61, 0xf8, 0xc0, 0xdf, 0x5e, 0x9c, 0x53, 0xd0, 0x32, 0x99, 0xa3, 0x05, - 0xda, 0x07, 0x6b, 0x6c, 0xb2, 0x20, 0x4b, 0x83, 0xb6, 0x63, 0xab, 0xd4, 0x32, 0xb7, 0x07, 0x5b, - 0xa5, 0x96, 0xb9, 0xf3, 0x49, 0x60, 0x72, 0x27, 0x99, 0x78, 0x92, 0x0c, 0x11, 0x86, 0xef, 0x25, - 0xdf, 0xa8, 0x80, 0x49, 0xd5, 0xdc, 0x26, 0x8a, 0x72, 0xfd, 0x93, 0x28, 0xca, 0x35, 0xba, 0x30, - 0x92, 0x55, 0x23, 0x98, 0xad, 0x2d, 0xc8, 0x72, 0xea, 0xd9, 0xee, 0x6f, 0xa1, 0xdd, 0x43, 0x2e, - 0x4d, 0x1b, 0xc1, 0xe8, 0xd6, 0xe6, 0xac, 0x60, 0xa4, 0x76, 0x3c, 0x84, 0x49, 0x16, 0xdf, 0xc6, - 0xc9, 0x63, 0x6c, 0x1d, 0xa0, 0x09, 0x3a, 0x0d, 0xc2, 0xe8, 0x3e, 0x0d, 0xa8, 0x45, 0xd0, 0x02, - 0xd3, 0xcf, 0xd2, 0x9b, 0x20, 0x4e, 0xa3, 0x4b, 0x3f, 0x0d, 0xac, 0x81, 0x73, 0x02, 0x3a, 0x65, - 0xa5, 0xe0, 0x9b, 0xf2, 0xdf, 0x5e, 0xde, 0x17, 0x01, 0x83, 0x2a, 0x70, 0xe6, 0x5d, 0xe3, 0x39, - 0x18, 0x3b, 0x76, 0x22, 0x10, 0xff, 0x36, 0x9a, 0x4f, 0x7b, 0x5a, 0x7b, 0x9a, 0x15, 0x1c, 0x85, - 0xac, 0x4a, 0x44, 0xc7, 0xd8, 0x33, 0xcc, 0x8f, 0x7b, 0x7b, 0x67, 0x3a, 0x03, 0x3d, 0x64, 0x95, - 0x2f, 0x44, 0x74, 0x85, 0xb3, 0x9e, 0xa1, 0x3d, 0xfa, 0x3e, 0xe2, 0x79, 0xac, 0xbe, 0xe7, 0xe2, - 0x3b, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xfa, 0x7d, 0x34, 0xb1, 0x01, 0x00, 0x00, -} diff --git a/remoteu2f-proxy/server.go b/remoteu2f-proxy/server.go index c63e82d..18b64a9 100644 --- a/remoteu2f-proxy/server.go +++ b/remoteu2f-proxy/server.go @@ -199,7 +199,7 @@ func (s *Server) GetOpResponse(ctx context.Context, url *pb.Url) (*pb.Response, // Remove the data once we've sent a reply. s.removeOp(url.Key) - return &pb.Response{reply}, nil + return &pb.Response{Json: reply}, nil } func (s *Server) GetAppID(ctx context.Context, _ *pb.Void) (*pb.Url, error) {