diff --git a/components/supervisor-api/go/backup.pb.go b/components/supervisor-api/go/backup.pb.go index 05c3b183222953..bb3ea2fe7d9150 100644 --- a/components/supervisor-api/go/backup.pb.go +++ b/components/supervisor-api/go/backup.pb.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + // Code generated by protoc-gen-go. DO NOT EDIT. // source: backup.proto diff --git a/components/supervisor-api/go/status.pb.go b/components/supervisor-api/go/status.pb.go index 2c58d18852c617..551714aa159152 100644 --- a/components/supervisor-api/go/status.pb.go +++ b/components/supervisor-api/go/status.pb.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + // Code generated by protoc-gen-go. DO NOT EDIT. // source: status.proto diff --git a/components/supervisor-api/go/status.pb.gw.go b/components/supervisor-api/go/status.pb.gw.go index 951d4ae1896f1a..9c8cf6a053d661 100644 --- a/components/supervisor-api/go/status.pb.gw.go +++ b/components/supervisor-api/go/status.pb.gw.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: status.proto diff --git a/components/supervisor-api/go/terminal.pb.go b/components/supervisor-api/go/terminal.pb.go index 82d208b804728f..67cab9083874cd 100644 --- a/components/supervisor-api/go/terminal.pb.go +++ b/components/supervisor-api/go/terminal.pb.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + // Code generated by protoc-gen-go. DO NOT EDIT. // source: terminal.proto diff --git a/components/supervisor-api/go/terminal.pb.gw.go b/components/supervisor-api/go/terminal.pb.gw.go index bf719d853012f1..e038230dd3dca7 100644 --- a/components/supervisor-api/go/terminal.pb.gw.go +++ b/components/supervisor-api/go/terminal.pb.gw.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: terminal.proto diff --git a/components/supervisor-api/go/token.pb.go b/components/supervisor-api/go/token.pb.go new file mode 100644 index 00000000000000..47480fba8aa066 --- /dev/null +++ b/components/supervisor-api/go/token.pb.go @@ -0,0 +1,813 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: token.proto + +package api + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + timestamp "github.com/golang/protobuf/ptypes/timestamp" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// 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.ProtoPackageIsVersion3 // please upgrade the proto package + +type TokenReuse int32 + +const ( + // REUSE_NEVER means the token can never be re-used. + // This mode only makes sense when providing a token in response to a request. + TokenReuse_REUSE_NEVER TokenReuse = 0 + // REUSE_EXACTLY means the token can only be reused when the requested scopes + // exactly match those of the token. + TokenReuse_REUSE_EXACTLY TokenReuse = 1 + // REUSE_WHEN_POSSIBLE means the token can be reused when the requested scopes + // are a subset of the token's scopes. + TokenReuse_REUSE_WHEN_POSSIBLE TokenReuse = 2 +) + +var TokenReuse_name = map[int32]string{ + 0: "REUSE_NEVER", + 1: "REUSE_EXACTLY", + 2: "REUSE_WHEN_POSSIBLE", +} + +var TokenReuse_value = map[string]int32{ + "REUSE_NEVER": 0, + "REUSE_EXACTLY": 1, + "REUSE_WHEN_POSSIBLE": 2, +} + +func (x TokenReuse) String() string { + return proto.EnumName(TokenReuse_name, int32(x)) +} + +func (TokenReuse) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{0} +} + +type GetTokenRequest struct { + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Scope []string `protobuf:"bytes,2,rep,name=scope,proto3" json:"scope,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTokenRequest) Reset() { *m = GetTokenRequest{} } +func (m *GetTokenRequest) String() string { return proto.CompactTextString(m) } +func (*GetTokenRequest) ProtoMessage() {} +func (*GetTokenRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{0} +} + +func (m *GetTokenRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTokenRequest.Unmarshal(m, b) +} +func (m *GetTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTokenRequest.Marshal(b, m, deterministic) +} +func (m *GetTokenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTokenRequest.Merge(m, src) +} +func (m *GetTokenRequest) XXX_Size() int { + return xxx_messageInfo_GetTokenRequest.Size(m) +} +func (m *GetTokenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetTokenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTokenRequest proto.InternalMessageInfo + +func (m *GetTokenRequest) GetHost() string { + if m != nil { + return m.Host + } + return "" +} + +func (m *GetTokenRequest) GetScope() []string { + if m != nil { + return m.Scope + } + return nil +} + +func (m *GetTokenRequest) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +type GetTokenResponse struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTokenResponse) Reset() { *m = GetTokenResponse{} } +func (m *GetTokenResponse) String() string { return proto.CompactTextString(m) } +func (*GetTokenResponse) ProtoMessage() {} +func (*GetTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{1} +} + +func (m *GetTokenResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTokenResponse.Unmarshal(m, b) +} +func (m *GetTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTokenResponse.Marshal(b, m, deterministic) +} +func (m *GetTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTokenResponse.Merge(m, src) +} +func (m *GetTokenResponse) XXX_Size() int { + return xxx_messageInfo_GetTokenResponse.Size(m) +} +func (m *GetTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTokenResponse proto.InternalMessageInfo + +func (m *GetTokenResponse) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +type SetTokenRequest struct { + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Scope []string `protobuf:"bytes,2,rep,name=scope,proto3" json:"scope,omitempty"` + Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` + ExpiryDate *timestamp.Timestamp `protobuf:"bytes,4,opt,name=expiry_date,json=expiryDate,proto3" json:"expiry_date,omitempty"` + Reuse TokenReuse `protobuf:"varint,5,opt,name=reuse,proto3,enum=supervisor.TokenReuse" json:"reuse,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetTokenRequest) Reset() { *m = SetTokenRequest{} } +func (m *SetTokenRequest) String() string { return proto.CompactTextString(m) } +func (*SetTokenRequest) ProtoMessage() {} +func (*SetTokenRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{2} +} + +func (m *SetTokenRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetTokenRequest.Unmarshal(m, b) +} +func (m *SetTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetTokenRequest.Marshal(b, m, deterministic) +} +func (m *SetTokenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetTokenRequest.Merge(m, src) +} +func (m *SetTokenRequest) XXX_Size() int { + return xxx_messageInfo_SetTokenRequest.Size(m) +} +func (m *SetTokenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SetTokenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SetTokenRequest proto.InternalMessageInfo + +func (m *SetTokenRequest) GetHost() string { + if m != nil { + return m.Host + } + return "" +} + +func (m *SetTokenRequest) GetScope() []string { + if m != nil { + return m.Scope + } + return nil +} + +func (m *SetTokenRequest) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *SetTokenRequest) GetExpiryDate() *timestamp.Timestamp { + if m != nil { + return m.ExpiryDate + } + return nil +} + +func (m *SetTokenRequest) GetReuse() TokenReuse { + if m != nil { + return m.Reuse + } + return TokenReuse_REUSE_NEVER +} + +type SetTokenResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetTokenResponse) Reset() { *m = SetTokenResponse{} } +func (m *SetTokenResponse) String() string { return proto.CompactTextString(m) } +func (*SetTokenResponse) ProtoMessage() {} +func (*SetTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{3} +} + +func (m *SetTokenResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetTokenResponse.Unmarshal(m, b) +} +func (m *SetTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetTokenResponse.Marshal(b, m, deterministic) +} +func (m *SetTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetTokenResponse.Merge(m, src) +} +func (m *SetTokenResponse) XXX_Size() int { + return xxx_messageInfo_SetTokenResponse.Size(m) +} +func (m *SetTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SetTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SetTokenResponse proto.InternalMessageInfo + +type ClearTokenRequest struct { + // Types that are valid to be assigned to Token: + // *ClearTokenRequest_Value + // *ClearTokenRequest_All + Token isClearTokenRequest_Token `protobuf_oneof:"token"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ClearTokenRequest) Reset() { *m = ClearTokenRequest{} } +func (m *ClearTokenRequest) String() string { return proto.CompactTextString(m) } +func (*ClearTokenRequest) ProtoMessage() {} +func (*ClearTokenRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{4} +} + +func (m *ClearTokenRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ClearTokenRequest.Unmarshal(m, b) +} +func (m *ClearTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ClearTokenRequest.Marshal(b, m, deterministic) +} +func (m *ClearTokenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClearTokenRequest.Merge(m, src) +} +func (m *ClearTokenRequest) XXX_Size() int { + return xxx_messageInfo_ClearTokenRequest.Size(m) +} +func (m *ClearTokenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ClearTokenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ClearTokenRequest proto.InternalMessageInfo + +type isClearTokenRequest_Token interface { + isClearTokenRequest_Token() +} + +type ClearTokenRequest_Value struct { + Value string `protobuf:"bytes,1,opt,name=value,proto3,oneof"` +} + +type ClearTokenRequest_All struct { + All bool `protobuf:"varint,2,opt,name=all,proto3,oneof"` +} + +func (*ClearTokenRequest_Value) isClearTokenRequest_Token() {} + +func (*ClearTokenRequest_All) isClearTokenRequest_Token() {} + +func (m *ClearTokenRequest) GetToken() isClearTokenRequest_Token { + if m != nil { + return m.Token + } + return nil +} + +func (m *ClearTokenRequest) GetValue() string { + if x, ok := m.GetToken().(*ClearTokenRequest_Value); ok { + return x.Value + } + return "" +} + +func (m *ClearTokenRequest) GetAll() bool { + if x, ok := m.GetToken().(*ClearTokenRequest_All); ok { + return x.All + } + return false +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ClearTokenRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ClearTokenRequest_Value)(nil), + (*ClearTokenRequest_All)(nil), + } +} + +type ClearTokenResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ClearTokenResponse) Reset() { *m = ClearTokenResponse{} } +func (m *ClearTokenResponse) String() string { return proto.CompactTextString(m) } +func (*ClearTokenResponse) ProtoMessage() {} +func (*ClearTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{5} +} + +func (m *ClearTokenResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ClearTokenResponse.Unmarshal(m, b) +} +func (m *ClearTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ClearTokenResponse.Marshal(b, m, deterministic) +} +func (m *ClearTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClearTokenResponse.Merge(m, src) +} +func (m *ClearTokenResponse) XXX_Size() int { + return xxx_messageInfo_ClearTokenResponse.Size(m) +} +func (m *ClearTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ClearTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ClearTokenResponse proto.InternalMessageInfo + +type ProvideTokenRequest struct { + // Types that are valid to be assigned to Message: + // *ProvideTokenRequest_Registration + // *ProvideTokenRequest_Answer + Message isProvideTokenRequest_Message `protobuf_oneof:"message"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProvideTokenRequest) Reset() { *m = ProvideTokenRequest{} } +func (m *ProvideTokenRequest) String() string { return proto.CompactTextString(m) } +func (*ProvideTokenRequest) ProtoMessage() {} +func (*ProvideTokenRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{6} +} + +func (m *ProvideTokenRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProvideTokenRequest.Unmarshal(m, b) +} +func (m *ProvideTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProvideTokenRequest.Marshal(b, m, deterministic) +} +func (m *ProvideTokenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProvideTokenRequest.Merge(m, src) +} +func (m *ProvideTokenRequest) XXX_Size() int { + return xxx_messageInfo_ProvideTokenRequest.Size(m) +} +func (m *ProvideTokenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ProvideTokenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ProvideTokenRequest proto.InternalMessageInfo + +type isProvideTokenRequest_Message interface { + isProvideTokenRequest_Message() +} + +type ProvideTokenRequest_Registration struct { + Registration *ProvideTokenRequest_RegisterProvider `protobuf:"bytes,1,opt,name=registration,proto3,oneof"` +} + +type ProvideTokenRequest_Answer struct { + Answer *SetTokenRequest `protobuf:"bytes,2,opt,name=answer,proto3,oneof"` +} + +func (*ProvideTokenRequest_Registration) isProvideTokenRequest_Message() {} + +func (*ProvideTokenRequest_Answer) isProvideTokenRequest_Message() {} + +func (m *ProvideTokenRequest) GetMessage() isProvideTokenRequest_Message { + if m != nil { + return m.Message + } + return nil +} + +func (m *ProvideTokenRequest) GetRegistration() *ProvideTokenRequest_RegisterProvider { + if x, ok := m.GetMessage().(*ProvideTokenRequest_Registration); ok { + return x.Registration + } + return nil +} + +func (m *ProvideTokenRequest) GetAnswer() *SetTokenRequest { + if x, ok := m.GetMessage().(*ProvideTokenRequest_Answer); ok { + return x.Answer + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ProvideTokenRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ProvideTokenRequest_Registration)(nil), + (*ProvideTokenRequest_Answer)(nil), + } +} + +type ProvideTokenRequest_RegisterProvider struct { + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProvideTokenRequest_RegisterProvider) Reset() { *m = ProvideTokenRequest_RegisterProvider{} } +func (m *ProvideTokenRequest_RegisterProvider) String() string { return proto.CompactTextString(m) } +func (*ProvideTokenRequest_RegisterProvider) ProtoMessage() {} +func (*ProvideTokenRequest_RegisterProvider) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{6, 0} +} + +func (m *ProvideTokenRequest_RegisterProvider) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProvideTokenRequest_RegisterProvider.Unmarshal(m, b) +} +func (m *ProvideTokenRequest_RegisterProvider) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProvideTokenRequest_RegisterProvider.Marshal(b, m, deterministic) +} +func (m *ProvideTokenRequest_RegisterProvider) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProvideTokenRequest_RegisterProvider.Merge(m, src) +} +func (m *ProvideTokenRequest_RegisterProvider) XXX_Size() int { + return xxx_messageInfo_ProvideTokenRequest_RegisterProvider.Size(m) +} +func (m *ProvideTokenRequest_RegisterProvider) XXX_DiscardUnknown() { + xxx_messageInfo_ProvideTokenRequest_RegisterProvider.DiscardUnknown(m) +} + +var xxx_messageInfo_ProvideTokenRequest_RegisterProvider proto.InternalMessageInfo + +func (m *ProvideTokenRequest_RegisterProvider) GetHost() string { + if m != nil { + return m.Host + } + return "" +} + +type ProvideTokenResponse struct { + Request *GetTokenRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProvideTokenResponse) Reset() { *m = ProvideTokenResponse{} } +func (m *ProvideTokenResponse) String() string { return proto.CompactTextString(m) } +func (*ProvideTokenResponse) ProtoMessage() {} +func (*ProvideTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3aff0bcd502840ab, []int{7} +} + +func (m *ProvideTokenResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProvideTokenResponse.Unmarshal(m, b) +} +func (m *ProvideTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProvideTokenResponse.Marshal(b, m, deterministic) +} +func (m *ProvideTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProvideTokenResponse.Merge(m, src) +} +func (m *ProvideTokenResponse) XXX_Size() int { + return xxx_messageInfo_ProvideTokenResponse.Size(m) +} +func (m *ProvideTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ProvideTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ProvideTokenResponse proto.InternalMessageInfo + +func (m *ProvideTokenResponse) GetRequest() *GetTokenRequest { + if m != nil { + return m.Request + } + return nil +} + +func init() { + proto.RegisterEnum("supervisor.TokenReuse", TokenReuse_name, TokenReuse_value) + proto.RegisterType((*GetTokenRequest)(nil), "supervisor.GetTokenRequest") + proto.RegisterType((*GetTokenResponse)(nil), "supervisor.GetTokenResponse") + proto.RegisterType((*SetTokenRequest)(nil), "supervisor.SetTokenRequest") + proto.RegisterType((*SetTokenResponse)(nil), "supervisor.SetTokenResponse") + proto.RegisterType((*ClearTokenRequest)(nil), "supervisor.ClearTokenRequest") + proto.RegisterType((*ClearTokenResponse)(nil), "supervisor.ClearTokenResponse") + proto.RegisterType((*ProvideTokenRequest)(nil), "supervisor.ProvideTokenRequest") + proto.RegisterType((*ProvideTokenRequest_RegisterProvider)(nil), "supervisor.ProvideTokenRequest.RegisterProvider") + proto.RegisterType((*ProvideTokenResponse)(nil), "supervisor.ProvideTokenResponse") +} + +func init() { + proto.RegisterFile("token.proto", fileDescriptor_3aff0bcd502840ab) +} + +var fileDescriptor_3aff0bcd502840ab = []byte{ + // 643 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x6e, 0xd3, 0x4e, + 0x10, 0x8e, 0x93, 0xa6, 0x7f, 0x26, 0xfd, 0xfd, 0xea, 0x6e, 0x4b, 0xb1, 0xdc, 0xd2, 0x5a, 0x3e, + 0x20, 0x2b, 0x42, 0x76, 0x09, 0xea, 0x85, 0x8a, 0x03, 0x29, 0x16, 0xa9, 0x54, 0x4a, 0x65, 0x97, + 0x16, 0x2a, 0xa1, 0x6a, 0x9b, 0x0e, 0xc1, 0xc2, 0x8d, 0xcd, 0xee, 0x3a, 0x80, 0xaa, 0x5c, 0x38, + 0x71, 0xe7, 0x75, 0x90, 0x78, 0x08, 0x0e, 0xbc, 0x00, 0x0f, 0x82, 0xbc, 0x76, 0x88, 0x93, 0xa6, + 0x45, 0xe2, 0xe6, 0xd9, 0x99, 0xf9, 0xbe, 0xf9, 0x66, 0x3e, 0x43, 0x4d, 0x44, 0xef, 0xb0, 0x6b, + 0xc7, 0x2c, 0x12, 0x11, 0x01, 0x9e, 0xc4, 0xc8, 0x7a, 0x01, 0x8f, 0x98, 0xbe, 0xd6, 0x89, 0xa2, + 0x4e, 0x88, 0x0e, 0x8d, 0x03, 0x87, 0x76, 0xbb, 0x91, 0xa0, 0x22, 0x88, 0xba, 0x3c, 0xab, 0xd4, + 0x37, 0xf2, 0xac, 0x8c, 0xce, 0x92, 0x37, 0x8e, 0x08, 0x2e, 0x90, 0x0b, 0x7a, 0x11, 0x67, 0x05, + 0xe6, 0x6b, 0x58, 0x78, 0x8a, 0xe2, 0x30, 0x05, 0xf7, 0xf0, 0x7d, 0x82, 0x5c, 0x10, 0x02, 0x53, + 0x6f, 0x23, 0x2e, 0x34, 0xc5, 0x50, 0xac, 0x39, 0x4f, 0x7e, 0x93, 0x65, 0xa8, 0xf2, 0x76, 0x14, + 0xa3, 0x56, 0x36, 0x2a, 0xd6, 0x9c, 0x97, 0x05, 0xc4, 0x80, 0xda, 0x39, 0xf2, 0x36, 0x0b, 0xe2, + 0x94, 0x53, 0xab, 0xc8, 0x86, 0xe2, 0x93, 0x69, 0x81, 0x3a, 0x84, 0xe7, 0x71, 0xd4, 0xe5, 0x98, + 0x62, 0x49, 0x31, 0x39, 0x41, 0x16, 0x98, 0xdf, 0x14, 0x58, 0xf0, 0xff, 0x79, 0x92, 0x3f, 0x98, + 0x95, 0x02, 0x26, 0xd9, 0x86, 0x1a, 0x7e, 0x8c, 0x03, 0xf6, 0xe9, 0xf4, 0x9c, 0x0a, 0xd4, 0xa6, + 0x0c, 0xc5, 0xaa, 0x35, 0x74, 0x3b, 0xdb, 0x89, 0x3d, 0xd8, 0x89, 0x7d, 0x38, 0xd8, 0x89, 0x07, + 0x59, 0xf9, 0x13, 0x2a, 0x90, 0xdc, 0x83, 0x2a, 0xc3, 0x84, 0xa3, 0x56, 0x35, 0x14, 0xeb, 0xff, + 0xc6, 0x8a, 0x3d, 0x5c, 0xba, 0x9d, 0x4f, 0x99, 0x70, 0xf4, 0xb2, 0x22, 0x93, 0x80, 0xea, 0x8f, + 0x09, 0x35, 0x5b, 0xb0, 0xb8, 0x13, 0x22, 0x65, 0x23, 0x9a, 0x56, 0xa0, 0xda, 0xa3, 0x61, 0x82, + 0x99, 0xa8, 0x56, 0xc9, 0xcb, 0x42, 0x42, 0xa0, 0x42, 0xc3, 0x50, 0x2b, 0x1b, 0x8a, 0x35, 0xdb, + 0x2a, 0x79, 0x69, 0xd0, 0x9c, 0xc9, 0x55, 0x99, 0xcb, 0x40, 0x8a, 0x48, 0x39, 0xfe, 0x4f, 0x05, + 0x96, 0x0e, 0x58, 0xd4, 0x0b, 0xce, 0x71, 0x84, 0xe2, 0x08, 0xe6, 0x19, 0x76, 0x02, 0x2e, 0x98, + 0xf4, 0x82, 0x64, 0xaa, 0x35, 0x36, 0x8b, 0x02, 0x26, 0xb4, 0xd9, 0x9e, 0xec, 0x41, 0x96, 0xe7, + 0x58, 0xab, 0xe4, 0x8d, 0xe0, 0x90, 0x2d, 0x98, 0xa6, 0x5d, 0xfe, 0x01, 0x99, 0x9c, 0xb2, 0xd6, + 0x58, 0x2d, 0x22, 0x8e, 0xdd, 0xae, 0x55, 0xf2, 0xf2, 0x62, 0xfd, 0x2e, 0xa8, 0xe3, 0xd0, 0x93, + 0x2e, 0xdb, 0x9c, 0x83, 0x99, 0x0b, 0xe4, 0x9c, 0x76, 0xd0, 0x7c, 0x06, 0xcb, 0xa3, 0x13, 0xe6, + 0xd6, 0xd9, 0x82, 0x19, 0x96, 0xe1, 0xe7, 0xa2, 0x46, 0x46, 0x18, 0x33, 0xb2, 0x37, 0xa8, 0xad, + 0xef, 0x02, 0x0c, 0x2f, 0x46, 0x16, 0xa0, 0xe6, 0xb9, 0x2f, 0x7c, 0xf7, 0x74, 0xdf, 0x3d, 0x72, + 0x3d, 0xb5, 0x44, 0x16, 0xe1, 0xbf, 0xec, 0xc1, 0x7d, 0xf9, 0x78, 0xe7, 0x70, 0xef, 0x95, 0xaa, + 0x90, 0xdb, 0xb0, 0x94, 0x3d, 0x1d, 0xb7, 0xdc, 0xfd, 0xd3, 0x83, 0xe7, 0xbe, 0xbf, 0xdb, 0xdc, + 0x73, 0xd5, 0x72, 0xe3, 0x7b, 0x05, 0xe6, 0x25, 0x96, 0x9f, 0xb2, 0xb6, 0x91, 0x74, 0x60, 0x76, + 0xc0, 0x4b, 0x6e, 0x9a, 0x46, 0x5f, 0x9b, 0x9c, 0xcc, 0x6f, 0x69, 0x7c, 0xfe, 0xf1, 0xeb, 0x6b, + 0x59, 0x27, 0x9a, 0xd3, 0xbb, 0xef, 0xc8, 0xa3, 0x3b, 0x97, 0xe9, 0x56, 0xfa, 0xce, 0xa5, 0x74, + 0x78, 0x9f, 0x9c, 0xc1, 0xac, 0x3f, 0x91, 0xc8, 0xbf, 0x89, 0xe8, 0x8a, 0x29, 0x57, 0x25, 0xd1, + 0x2d, 0x53, 0x1d, 0x27, 0x7a, 0xa8, 0xd4, 0xc9, 0x17, 0x05, 0x60, 0x68, 0x34, 0x72, 0xa7, 0x88, + 0x74, 0xc5, 0xca, 0xfa, 0xfa, 0x75, 0xe9, 0x9c, 0x6a, 0x5b, 0x52, 0x6d, 0xd5, 0x17, 0x0b, 0x54, + 0xd2, 0xec, 0xfd, 0x13, 0xa3, 0xbe, 0x3e, 0x7c, 0x6c, 0xa7, 0xad, 0x0e, 0x0d, 0x43, 0xe7, 0x92, + 0x86, 0xe1, 0x23, 0xc1, 0x12, 0xec, 0x93, 0x63, 0x98, 0x2f, 0x5a, 0x80, 0x6c, 0xfc, 0xc5, 0xbe, + 0xba, 0x71, 0x7d, 0x41, 0x3e, 0x4f, 0xc9, 0x52, 0x36, 0x95, 0x66, 0xf5, 0xa4, 0x42, 0xe3, 0xe0, + 0x6c, 0x5a, 0xfe, 0xfe, 0x0f, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x12, 0xe8, 0x9a, 0x59, + 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// TokenServiceClient is the client API for TokenService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type TokenServiceClient interface { + GetToken(ctx context.Context, in *GetTokenRequest, opts ...grpc.CallOption) (*GetTokenResponse, error) + SetToken(ctx context.Context, in *SetTokenRequest, opts ...grpc.CallOption) (*SetTokenResponse, error) + ClearToken(ctx context.Context, in *ClearTokenRequest, opts ...grpc.CallOption) (*ClearTokenResponse, error) + ProvideToken(ctx context.Context, opts ...grpc.CallOption) (TokenService_ProvideTokenClient, error) +} + +type tokenServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTokenServiceClient(cc grpc.ClientConnInterface) TokenServiceClient { + return &tokenServiceClient{cc} +} + +func (c *tokenServiceClient) GetToken(ctx context.Context, in *GetTokenRequest, opts ...grpc.CallOption) (*GetTokenResponse, error) { + out := new(GetTokenResponse) + err := c.cc.Invoke(ctx, "/supervisor.TokenService/GetToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tokenServiceClient) SetToken(ctx context.Context, in *SetTokenRequest, opts ...grpc.CallOption) (*SetTokenResponse, error) { + out := new(SetTokenResponse) + err := c.cc.Invoke(ctx, "/supervisor.TokenService/SetToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tokenServiceClient) ClearToken(ctx context.Context, in *ClearTokenRequest, opts ...grpc.CallOption) (*ClearTokenResponse, error) { + out := new(ClearTokenResponse) + err := c.cc.Invoke(ctx, "/supervisor.TokenService/ClearToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tokenServiceClient) ProvideToken(ctx context.Context, opts ...grpc.CallOption) (TokenService_ProvideTokenClient, error) { + stream, err := c.cc.NewStream(ctx, &_TokenService_serviceDesc.Streams[0], "/supervisor.TokenService/ProvideToken", opts...) + if err != nil { + return nil, err + } + x := &tokenServiceProvideTokenClient{stream} + return x, nil +} + +type TokenService_ProvideTokenClient interface { + Send(*ProvideTokenRequest) error + Recv() (*ProvideTokenResponse, error) + grpc.ClientStream +} + +type tokenServiceProvideTokenClient struct { + grpc.ClientStream +} + +func (x *tokenServiceProvideTokenClient) Send(m *ProvideTokenRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *tokenServiceProvideTokenClient) Recv() (*ProvideTokenResponse, error) { + m := new(ProvideTokenResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TokenServiceServer is the server API for TokenService service. +type TokenServiceServer interface { + GetToken(context.Context, *GetTokenRequest) (*GetTokenResponse, error) + SetToken(context.Context, *SetTokenRequest) (*SetTokenResponse, error) + ClearToken(context.Context, *ClearTokenRequest) (*ClearTokenResponse, error) + ProvideToken(TokenService_ProvideTokenServer) error +} + +// UnimplementedTokenServiceServer can be embedded to have forward compatible implementations. +type UnimplementedTokenServiceServer struct { +} + +func (*UnimplementedTokenServiceServer) GetToken(ctx context.Context, req *GetTokenRequest) (*GetTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetToken not implemented") +} +func (*UnimplementedTokenServiceServer) SetToken(ctx context.Context, req *SetTokenRequest) (*SetTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetToken not implemented") +} +func (*UnimplementedTokenServiceServer) ClearToken(ctx context.Context, req *ClearTokenRequest) (*ClearTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClearToken not implemented") +} +func (*UnimplementedTokenServiceServer) ProvideToken(srv TokenService_ProvideTokenServer) error { + return status.Errorf(codes.Unimplemented, "method ProvideToken not implemented") +} + +func RegisterTokenServiceServer(s *grpc.Server, srv TokenServiceServer) { + s.RegisterService(&_TokenService_serviceDesc, srv) +} + +func _TokenService_GetToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TokenServiceServer).GetToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/supervisor.TokenService/GetToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TokenServiceServer).GetToken(ctx, req.(*GetTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TokenService_SetToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TokenServiceServer).SetToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/supervisor.TokenService/SetToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TokenServiceServer).SetToken(ctx, req.(*SetTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TokenService_ClearToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClearTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TokenServiceServer).ClearToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/supervisor.TokenService/ClearToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TokenServiceServer).ClearToken(ctx, req.(*ClearTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TokenService_ProvideToken_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TokenServiceServer).ProvideToken(&tokenServiceProvideTokenServer{stream}) +} + +type TokenService_ProvideTokenServer interface { + Send(*ProvideTokenResponse) error + Recv() (*ProvideTokenRequest, error) + grpc.ServerStream +} + +type tokenServiceProvideTokenServer struct { + grpc.ServerStream +} + +func (x *tokenServiceProvideTokenServer) Send(m *ProvideTokenResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *tokenServiceProvideTokenServer) Recv() (*ProvideTokenRequest, error) { + m := new(ProvideTokenRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _TokenService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "supervisor.TokenService", + HandlerType: (*TokenServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetToken", + Handler: _TokenService_GetToken_Handler, + }, + { + MethodName: "SetToken", + Handler: _TokenService_SetToken_Handler, + }, + { + MethodName: "ClearToken", + Handler: _TokenService_ClearToken_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "ProvideToken", + Handler: _TokenService_ProvideToken_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "token.proto", +} diff --git a/components/supervisor-api/go/token.pb.gw.go b/components/supervisor-api/go/token.pb.gw.go new file mode 100644 index 00000000000000..13e95662548831 --- /dev/null +++ b/components/supervisor-api/go/token.pb.gw.go @@ -0,0 +1,608 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: token.proto + +/* +Package api is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package api + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_TokenService_GetToken_0 = &utilities.DoubleArray{Encoding: map[string]int{"host": 0, "scope": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_TokenService_GetToken_0(ctx context.Context, marshaler runtime.Marshaler, client TokenServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["host"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "host") + } + + protoReq.Host, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host", err) + } + + val, ok = pathParams["scope"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "scope") + } + + protoReq.Scope, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "scope", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_GetToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TokenService_GetToken_0(ctx context.Context, marshaler runtime.Marshaler, server TokenServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["host"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "host") + } + + protoReq.Host, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host", err) + } + + val, ok = pathParams["scope"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "scope") + } + + protoReq.Scope, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "scope", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_GetToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetToken(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TokenService_SetToken_0(ctx context.Context, marshaler runtime.Marshaler, client TokenServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetTokenRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["host"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "host") + } + + protoReq.Host, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host", err) + } + + msg, err := client.SetToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TokenService_SetToken_0(ctx context.Context, marshaler runtime.Marshaler, server TokenServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetTokenRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["host"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "host") + } + + protoReq.Host, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host", err) + } + + msg, err := server.SetToken(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_TokenService_ClearToken_0 = &utilities.DoubleArray{Encoding: map[string]int{"value": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_TokenService_ClearToken_0(ctx context.Context, marshaler runtime.Marshaler, client TokenServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ClearTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["value"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") + } + + if protoReq.Token == nil { + protoReq.Token = &ClearTokenRequest_Value{} + } else if _, ok := protoReq.Token.(*ClearTokenRequest_Value); !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *ClearTokenRequest_Value, but: %t\n", protoReq.Token) + } + protoReq.Token.(*ClearTokenRequest_Value).Value, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_ClearToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ClearToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TokenService_ClearToken_0(ctx context.Context, marshaler runtime.Marshaler, server TokenServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ClearTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["value"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") + } + + if protoReq.Token == nil { + protoReq.Token = &ClearTokenRequest_Value{} + } else if _, ok := protoReq.Token.(*ClearTokenRequest_Value); !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *ClearTokenRequest_Value, but: %t\n", protoReq.Token) + } + protoReq.Token.(*ClearTokenRequest_Value).Value, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_ClearToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ClearToken(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_TokenService_ClearToken_1 = &utilities.DoubleArray{Encoding: map[string]int{"all": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_TokenService_ClearToken_1(ctx context.Context, marshaler runtime.Marshaler, client TokenServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ClearTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["all"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "all") + } + + if protoReq.Token == nil { + protoReq.Token = &ClearTokenRequest_All{} + } else if _, ok := protoReq.Token.(*ClearTokenRequest_All); !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *ClearTokenRequest_All, but: %t\n", protoReq.Token) + } + protoReq.Token.(*ClearTokenRequest_All).All, err = runtime.Bool(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "all", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_ClearToken_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ClearToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TokenService_ClearToken_1(ctx context.Context, marshaler runtime.Marshaler, server TokenServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ClearTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["all"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "all") + } + + if protoReq.Token == nil { + protoReq.Token = &ClearTokenRequest_All{} + } else if _, ok := protoReq.Token.(*ClearTokenRequest_All); !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *ClearTokenRequest_All, but: %t\n", protoReq.Token) + } + protoReq.Token.(*ClearTokenRequest_All).All, err = runtime.Bool(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "all", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TokenService_ClearToken_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ClearToken(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterTokenServiceHandlerServer registers the http handlers for service TokenService to "mux". +// UnaryRPC :call TokenServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTokenServiceHandlerFromEndpoint instead. +func RegisterTokenServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TokenServiceServer) error { + + mux.Handle("GET", pattern_TokenService_GetToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TokenService_GetToken_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_GetToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TokenService_SetToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TokenService_SetToken_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_SetToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TokenService_ClearToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TokenService_ClearToken_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_ClearToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TokenService_ClearToken_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TokenService_ClearToken_1(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_ClearToken_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterTokenServiceHandlerFromEndpoint is same as RegisterTokenServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterTokenServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterTokenServiceHandler(ctx, mux, conn) +} + +// RegisterTokenServiceHandler registers the http handlers for service TokenService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterTokenServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterTokenServiceHandlerClient(ctx, mux, NewTokenServiceClient(conn)) +} + +// RegisterTokenServiceHandlerClient registers the http handlers for service TokenService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TokenServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TokenServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "TokenServiceClient" to call the correct interceptors. +func RegisterTokenServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TokenServiceClient) error { + + mux.Handle("GET", pattern_TokenService_GetToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TokenService_GetToken_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_GetToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TokenService_SetToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TokenService_SetToken_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_SetToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TokenService_ClearToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TokenService_ClearToken_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_ClearToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TokenService_ClearToken_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TokenService_ClearToken_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TokenService_ClearToken_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_TokenService_GetToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "token", "host", "scope"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_TokenService_SetToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "token", "host"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_TokenService_ClearToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "token", "value"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_TokenService_ClearToken_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 4, 1, 5, 3}, []string{"v1", "token", "clear", "all", "true"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_TokenService_GetToken_0 = runtime.ForwardResponseMessage + + forward_TokenService_SetToken_0 = runtime.ForwardResponseMessage + + forward_TokenService_ClearToken_0 = runtime.ForwardResponseMessage + + forward_TokenService_ClearToken_1 = runtime.ForwardResponseMessage +) diff --git a/components/supervisor-api/token.proto b/components/supervisor-api/token.proto new file mode 100644 index 00000000000000..be5f41a6b346d9 --- /dev/null +++ b/components/supervisor-api/token.proto @@ -0,0 +1,89 @@ +syntax = "proto3"; + +package supervisor; + +import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "api"; + +service TokenService { + rpc GetToken(GetTokenRequest) returns (GetTokenResponse) { + option (google.api.http) = { + get: "/v1/token/{host}/{scope}" + }; + } + + rpc SetToken(SetTokenRequest) returns (SetTokenResponse) { + option (google.api.http) = { + post: "/v1/token/{host}" + body: "*" + }; + } + + rpc ClearToken(ClearTokenRequest) returns (ClearTokenResponse) { + option (google.api.http) = { + delete: "/v1/token/{value}", + additional_bindings { + delete: "/v1/token/clear/all/{all=true}", + } + }; + } + + rpc ProvideToken(stream ProvideTokenRequest) returns (stream ProvideTokenResponse) {} +} + +message GetTokenRequest { + string host = 1; + repeated string scope = 2; + string description = 3; +} +message GetTokenResponse { + string token = 1; +} + +message SetTokenRequest { + string host = 1; + repeated string scope = 2; + string token = 3; + google.protobuf.Timestamp expiry_date = 4; + TokenReuse reuse = 5; +} +message SetTokenResponse {} + +enum TokenReuse { + // REUSE_NEVER means the token can never be re-used. + // This mode only makes sense when providing a token in response to a request. + REUSE_NEVER = 0; + + // REUSE_EXACTLY means the token can only be reused when the requested scopes + // exactly match those of the token. + REUSE_EXACTLY = 1; + + // REUSE_WHEN_POSSIBLE means the token can be reused when the requested scopes + // are a subset of the token's scopes. + REUSE_WHEN_POSSIBLE = 2; +} + +message ClearTokenRequest { + oneof token { + string value = 1; + bool all = 2; + }; +} + +message ClearTokenResponse {} + +message ProvideTokenRequest { + message RegisterProvider { + string host = 1; + } + + oneof message { + RegisterProvider registration = 1; + SetTokenRequest answer = 2; + }; +} +message ProvideTokenResponse { + GetTokenRequest request = 1; +} diff --git a/components/supervisor-api/typescript/src/backup_grpc_pb.d.ts b/components/supervisor-api/typescript/src/backup_grpc_pb.d.ts index 7c1e62b3384ad2..e43baf7e401712 100644 --- a/components/supervisor-api/typescript/src/backup_grpc_pb.d.ts +++ b/components/supervisor-api/typescript/src/backup_grpc_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: backup.proto diff --git a/components/supervisor-api/typescript/src/backup_grpc_pb.js b/components/supervisor-api/typescript/src/backup_grpc_pb.js index 6d7b2ca156aa1b..daa518a4c99a33 100644 --- a/components/supervisor-api/typescript/src/backup_grpc_pb.js +++ b/components/supervisor-api/typescript/src/backup_grpc_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // GENERATED CODE -- DO NOT EDIT! 'use strict'; diff --git a/components/supervisor-api/typescript/src/backup_pb.d.ts b/components/supervisor-api/typescript/src/backup_pb.d.ts index a3544f553c75e5..6f84b783119910 100644 --- a/components/supervisor-api/typescript/src/backup_pb.d.ts +++ b/components/supervisor-api/typescript/src/backup_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: backup.proto diff --git a/components/supervisor-api/typescript/src/backup_pb.js b/components/supervisor-api/typescript/src/backup_pb.js index fd91aa1c053e9b..f3fd1c4c5f2f9c 100644 --- a/components/supervisor-api/typescript/src/backup_pb.js +++ b/components/supervisor-api/typescript/src/backup_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + /** * @fileoverview * @enhanceable diff --git a/components/supervisor-api/typescript/src/status_grpc_pb.d.ts b/components/supervisor-api/typescript/src/status_grpc_pb.d.ts index 8f1445b3840e74..01d38d6be45534 100644 --- a/components/supervisor-api/typescript/src/status_grpc_pb.d.ts +++ b/components/supervisor-api/typescript/src/status_grpc_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: status.proto diff --git a/components/supervisor-api/typescript/src/status_grpc_pb.js b/components/supervisor-api/typescript/src/status_grpc_pb.js index 456488e1b7c863..61caa70679807e 100644 --- a/components/supervisor-api/typescript/src/status_grpc_pb.js +++ b/components/supervisor-api/typescript/src/status_grpc_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // GENERATED CODE -- DO NOT EDIT! 'use strict'; diff --git a/components/supervisor-api/typescript/src/status_pb.d.ts b/components/supervisor-api/typescript/src/status_pb.d.ts index aec78fcc594d3e..a630925c6b2e38 100644 --- a/components/supervisor-api/typescript/src/status_pb.d.ts +++ b/components/supervisor-api/typescript/src/status_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: status.proto diff --git a/components/supervisor-api/typescript/src/status_pb.js b/components/supervisor-api/typescript/src/status_pb.js index 8bd7c946aeffb4..5c467363fd3e1d 100644 --- a/components/supervisor-api/typescript/src/status_pb.js +++ b/components/supervisor-api/typescript/src/status_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + /** * @fileoverview * @enhanceable diff --git a/components/supervisor-api/typescript/src/terminal_grpc_pb.d.ts b/components/supervisor-api/typescript/src/terminal_grpc_pb.d.ts index 8680381d1845d7..7fb6a668dcd50d 100644 --- a/components/supervisor-api/typescript/src/terminal_grpc_pb.d.ts +++ b/components/supervisor-api/typescript/src/terminal_grpc_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: terminal.proto diff --git a/components/supervisor-api/typescript/src/terminal_grpc_pb.js b/components/supervisor-api/typescript/src/terminal_grpc_pb.js index 5625ddb829744a..d870a4f674899b 100644 --- a/components/supervisor-api/typescript/src/terminal_grpc_pb.js +++ b/components/supervisor-api/typescript/src/terminal_grpc_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // GENERATED CODE -- DO NOT EDIT! 'use strict'; diff --git a/components/supervisor-api/typescript/src/terminal_pb.d.ts b/components/supervisor-api/typescript/src/terminal_pb.d.ts index b58e44db94b957..ac81046ec00d79 100644 --- a/components/supervisor-api/typescript/src/terminal_pb.d.ts +++ b/components/supervisor-api/typescript/src/terminal_pb.d.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + // package: supervisor // file: terminal.proto diff --git a/components/supervisor-api/typescript/src/terminal_pb.js b/components/supervisor-api/typescript/src/terminal_pb.js index 6d9bf445dd5aa4..82a0d7483d00e9 100644 --- a/components/supervisor-api/typescript/src/terminal_pb.js +++ b/components/supervisor-api/typescript/src/terminal_pb.js @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + /** * @fileoverview * @enhanceable diff --git a/components/supervisor-api/typescript/src/token_grpc_pb.d.ts b/components/supervisor-api/typescript/src/token_grpc_pb.d.ts new file mode 100644 index 00000000000000..0bcf0df1391d9f --- /dev/null +++ b/components/supervisor-api/typescript/src/token_grpc_pb.d.ts @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: supervisor +// file: token.proto + +/* tslint:disable */ + +import * as grpc from "grpc"; +import * as token_pb from "./token_pb"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; + +interface ITokenServiceService extends grpc.ServiceDefinition { + getToken: ITokenServiceService_IGetToken; + setToken: ITokenServiceService_ISetToken; + clearToken: ITokenServiceService_IClearToken; + provideToken: ITokenServiceService_IProvideToken; +} + +interface ITokenServiceService_IGetToken extends grpc.MethodDefinition { + path: string; // "/supervisor.TokenService/GetToken" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ITokenServiceService_ISetToken extends grpc.MethodDefinition { + path: string; // "/supervisor.TokenService/SetToken" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ITokenServiceService_IClearToken extends grpc.MethodDefinition { + path: string; // "/supervisor.TokenService/ClearToken" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ITokenServiceService_IProvideToken extends grpc.MethodDefinition { + path: string; // "/supervisor.TokenService/ProvideToken" + requestStream: boolean; // true + responseStream: boolean; // true + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const TokenServiceService: ITokenServiceService; + +export interface ITokenServiceServer { + getToken: grpc.handleUnaryCall; + setToken: grpc.handleUnaryCall; + clearToken: grpc.handleUnaryCall; + provideToken: grpc.handleBidiStreamingCall; +} + +export interface ITokenServiceClient { + getToken(request: token_pb.GetTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + getToken(request: token_pb.GetTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + getToken(request: token_pb.GetTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + setToken(request: token_pb.SetTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + setToken(request: token_pb.SetTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + setToken(request: token_pb.SetTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + clearToken(request: token_pb.ClearTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + clearToken(request: token_pb.ClearTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + clearToken(request: token_pb.ClearTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + provideToken(): grpc.ClientDuplexStream; + provideToken(options: Partial): grpc.ClientDuplexStream; + provideToken(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} + +export class TokenServiceClient extends grpc.Client implements ITokenServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); + public getToken(request: token_pb.GetTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + public getToken(request: token_pb.GetTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + public getToken(request: token_pb.GetTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.GetTokenResponse) => void): grpc.ClientUnaryCall; + public setToken(request: token_pb.SetTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + public setToken(request: token_pb.SetTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + public setToken(request: token_pb.SetTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.SetTokenResponse) => void): grpc.ClientUnaryCall; + public clearToken(request: token_pb.ClearTokenRequest, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + public clearToken(request: token_pb.ClearTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + public clearToken(request: token_pb.ClearTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: token_pb.ClearTokenResponse) => void): grpc.ClientUnaryCall; + public provideToken(options?: Partial): grpc.ClientDuplexStream; + public provideToken(metadata?: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} diff --git a/components/supervisor-api/typescript/src/token_grpc_pb.js b/components/supervisor-api/typescript/src/token_grpc_pb.js new file mode 100644 index 00000000000000..54ec48c34db2fd --- /dev/null +++ b/components/supervisor-api/typescript/src/token_grpc_pb.js @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// GENERATED CODE -- DO NOT EDIT! + +'use strict'; +var grpc = require('@grpc/grpc-js'); +var token_pb = require('./token_pb.js'); +var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); + +function serialize_supervisor_ClearTokenRequest(arg) { + if (!(arg instanceof token_pb.ClearTokenRequest)) { + throw new Error('Expected argument of type supervisor.ClearTokenRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_ClearTokenRequest(buffer_arg) { + return token_pb.ClearTokenRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_ClearTokenResponse(arg) { + if (!(arg instanceof token_pb.ClearTokenResponse)) { + throw new Error('Expected argument of type supervisor.ClearTokenResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_ClearTokenResponse(buffer_arg) { + return token_pb.ClearTokenResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_GetTokenRequest(arg) { + if (!(arg instanceof token_pb.GetTokenRequest)) { + throw new Error('Expected argument of type supervisor.GetTokenRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_GetTokenRequest(buffer_arg) { + return token_pb.GetTokenRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_GetTokenResponse(arg) { + if (!(arg instanceof token_pb.GetTokenResponse)) { + throw new Error('Expected argument of type supervisor.GetTokenResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_GetTokenResponse(buffer_arg) { + return token_pb.GetTokenResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_ProvideTokenRequest(arg) { + if (!(arg instanceof token_pb.ProvideTokenRequest)) { + throw new Error('Expected argument of type supervisor.ProvideTokenRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_ProvideTokenRequest(buffer_arg) { + return token_pb.ProvideTokenRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_ProvideTokenResponse(arg) { + if (!(arg instanceof token_pb.ProvideTokenResponse)) { + throw new Error('Expected argument of type supervisor.ProvideTokenResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_ProvideTokenResponse(buffer_arg) { + return token_pb.ProvideTokenResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_SetTokenRequest(arg) { + if (!(arg instanceof token_pb.SetTokenRequest)) { + throw new Error('Expected argument of type supervisor.SetTokenRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_SetTokenRequest(buffer_arg) { + return token_pb.SetTokenRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_supervisor_SetTokenResponse(arg) { + if (!(arg instanceof token_pb.SetTokenResponse)) { + throw new Error('Expected argument of type supervisor.SetTokenResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_supervisor_SetTokenResponse(buffer_arg) { + return token_pb.SetTokenResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var TokenServiceService = exports.TokenServiceService = { + getToken: { + path: '/supervisor.TokenService/GetToken', + requestStream: false, + responseStream: false, + requestType: token_pb.GetTokenRequest, + responseType: token_pb.GetTokenResponse, + requestSerialize: serialize_supervisor_GetTokenRequest, + requestDeserialize: deserialize_supervisor_GetTokenRequest, + responseSerialize: serialize_supervisor_GetTokenResponse, + responseDeserialize: deserialize_supervisor_GetTokenResponse, + }, + setToken: { + path: '/supervisor.TokenService/SetToken', + requestStream: false, + responseStream: false, + requestType: token_pb.SetTokenRequest, + responseType: token_pb.SetTokenResponse, + requestSerialize: serialize_supervisor_SetTokenRequest, + requestDeserialize: deserialize_supervisor_SetTokenRequest, + responseSerialize: serialize_supervisor_SetTokenResponse, + responseDeserialize: deserialize_supervisor_SetTokenResponse, + }, + clearToken: { + path: '/supervisor.TokenService/ClearToken', + requestStream: false, + responseStream: false, + requestType: token_pb.ClearTokenRequest, + responseType: token_pb.ClearTokenResponse, + requestSerialize: serialize_supervisor_ClearTokenRequest, + requestDeserialize: deserialize_supervisor_ClearTokenRequest, + responseSerialize: serialize_supervisor_ClearTokenResponse, + responseDeserialize: deserialize_supervisor_ClearTokenResponse, + }, + provideToken: { + path: '/supervisor.TokenService/ProvideToken', + requestStream: true, + responseStream: true, + requestType: token_pb.ProvideTokenRequest, + responseType: token_pb.ProvideTokenResponse, + requestSerialize: serialize_supervisor_ProvideTokenRequest, + requestDeserialize: deserialize_supervisor_ProvideTokenRequest, + responseSerialize: serialize_supervisor_ProvideTokenResponse, + responseDeserialize: deserialize_supervisor_ProvideTokenResponse, + }, +}; + +exports.TokenServiceClient = grpc.makeGenericClientConstructor(TokenServiceService); diff --git a/components/supervisor-api/typescript/src/token_pb.d.ts b/components/supervisor-api/typescript/src/token_pb.d.ts new file mode 100644 index 00000000000000..225b9a2e0d4df9 --- /dev/null +++ b/components/supervisor-api/typescript/src/token_pb.d.ts @@ -0,0 +1,280 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: supervisor +// file: token.proto + +/* tslint:disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; + +export class GetTokenRequest extends jspb.Message { + getHost(): string; + setHost(value: string): void; + + clearScopeList(): void; + getScopeList(): Array; + setScopeList(value: Array): void; + addScope(value: string, index?: number): string; + + getDescription(): string; + setDescription(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTokenRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetTokenRequest): GetTokenRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTokenRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTokenRequest; + static deserializeBinaryFromReader(message: GetTokenRequest, reader: jspb.BinaryReader): GetTokenRequest; +} + +export namespace GetTokenRequest { + export type AsObject = { + host: string, + scopeList: Array, + description: string, + } +} + +export class GetTokenResponse extends jspb.Message { + getToken(): string; + setToken(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTokenResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetTokenResponse): GetTokenResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTokenResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTokenResponse; + static deserializeBinaryFromReader(message: GetTokenResponse, reader: jspb.BinaryReader): GetTokenResponse; +} + +export namespace GetTokenResponse { + export type AsObject = { + token: string, + } +} + +export class SetTokenRequest extends jspb.Message { + getHost(): string; + setHost(value: string): void; + + clearScopeList(): void; + getScopeList(): Array; + setScopeList(value: Array): void; + addScope(value: string, index?: number): string; + + getToken(): string; + setToken(value: string): void; + + + hasExpiryDate(): boolean; + clearExpiryDate(): void; + getExpiryDate(): google_protobuf_timestamp_pb.Timestamp | undefined; + setExpiryDate(value?: google_protobuf_timestamp_pb.Timestamp): void; + + getReuse(): TokenReuse; + setReuse(value: TokenReuse): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetTokenRequest.AsObject; + static toObject(includeInstance: boolean, msg: SetTokenRequest): SetTokenRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetTokenRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetTokenRequest; + static deserializeBinaryFromReader(message: SetTokenRequest, reader: jspb.BinaryReader): SetTokenRequest; +} + +export namespace SetTokenRequest { + export type AsObject = { + host: string, + scopeList: Array, + token: string, + expiryDate?: google_protobuf_timestamp_pb.Timestamp.AsObject, + reuse: TokenReuse, + } +} + +export class SetTokenResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetTokenResponse.AsObject; + static toObject(includeInstance: boolean, msg: SetTokenResponse): SetTokenResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetTokenResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetTokenResponse; + static deserializeBinaryFromReader(message: SetTokenResponse, reader: jspb.BinaryReader): SetTokenResponse; +} + +export namespace SetTokenResponse { + export type AsObject = { + } +} + +export class ClearTokenRequest extends jspb.Message { + + hasValue(): boolean; + clearValue(): void; + getValue(): string; + setValue(value: string): void; + + + hasAll(): boolean; + clearAll(): void; + getAll(): boolean; + setAll(value: boolean): void; + + + getTokenCase(): ClearTokenRequest.TokenCase; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ClearTokenRequest.AsObject; + static toObject(includeInstance: boolean, msg: ClearTokenRequest): ClearTokenRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ClearTokenRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ClearTokenRequest; + static deserializeBinaryFromReader(message: ClearTokenRequest, reader: jspb.BinaryReader): ClearTokenRequest; +} + +export namespace ClearTokenRequest { + export type AsObject = { + value: string, + all: boolean, + } + + export enum TokenCase { + TOKEN_NOT_SET = 0, + + VALUE = 1, + + ALL = 2, + + } + +} + +export class ClearTokenResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ClearTokenResponse.AsObject; + static toObject(includeInstance: boolean, msg: ClearTokenResponse): ClearTokenResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ClearTokenResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ClearTokenResponse; + static deserializeBinaryFromReader(message: ClearTokenResponse, reader: jspb.BinaryReader): ClearTokenResponse; +} + +export namespace ClearTokenResponse { + export type AsObject = { + } +} + +export class ProvideTokenRequest extends jspb.Message { + + hasRegistration(): boolean; + clearRegistration(): void; + getRegistration(): ProvideTokenRequest.RegisterProvider | undefined; + setRegistration(value?: ProvideTokenRequest.RegisterProvider): void; + + + hasAnswer(): boolean; + clearAnswer(): void; + getAnswer(): SetTokenRequest | undefined; + setAnswer(value?: SetTokenRequest): void; + + + getMessageCase(): ProvideTokenRequest.MessageCase; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProvideTokenRequest.AsObject; + static toObject(includeInstance: boolean, msg: ProvideTokenRequest): ProvideTokenRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ProvideTokenRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProvideTokenRequest; + static deserializeBinaryFromReader(message: ProvideTokenRequest, reader: jspb.BinaryReader): ProvideTokenRequest; +} + +export namespace ProvideTokenRequest { + export type AsObject = { + registration?: ProvideTokenRequest.RegisterProvider.AsObject, + answer?: SetTokenRequest.AsObject, + } + + + export class RegisterProvider extends jspb.Message { + getHost(): string; + setHost(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RegisterProvider.AsObject; + static toObject(includeInstance: boolean, msg: RegisterProvider): RegisterProvider.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RegisterProvider, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RegisterProvider; + static deserializeBinaryFromReader(message: RegisterProvider, reader: jspb.BinaryReader): RegisterProvider; + } + + export namespace RegisterProvider { + export type AsObject = { + host: string, + } + } + + + export enum MessageCase { + MESSAGE_NOT_SET = 0, + + REGISTRATION = 1, + + ANSWER = 2, + + } + +} + +export class ProvideTokenResponse extends jspb.Message { + + hasRequest(): boolean; + clearRequest(): void; + getRequest(): GetTokenRequest | undefined; + setRequest(value?: GetTokenRequest): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProvideTokenResponse.AsObject; + static toObject(includeInstance: boolean, msg: ProvideTokenResponse): ProvideTokenResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ProvideTokenResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProvideTokenResponse; + static deserializeBinaryFromReader(message: ProvideTokenResponse, reader: jspb.BinaryReader): ProvideTokenResponse; +} + +export namespace ProvideTokenResponse { + export type AsObject = { + request?: GetTokenRequest.AsObject, + } +} + +export enum TokenReuse { + REUSE_NEVER = 0, + REUSE_EXACTLY = 1, + REUSE_WHEN_POSSIBLE = 2, +} diff --git a/components/supervisor-api/typescript/src/token_pb.js b/components/supervisor-api/typescript/src/token_pb.js new file mode 100644 index 00000000000000..13ff348462fc4f --- /dev/null +++ b/components/supervisor-api/typescript/src/token_pb.js @@ -0,0 +1,1735 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); +goog.object.extend(proto, google_protobuf_timestamp_pb); +goog.exportSymbol('proto.supervisor.ClearTokenRequest', null, global); +goog.exportSymbol('proto.supervisor.ClearTokenResponse', null, global); +goog.exportSymbol('proto.supervisor.GetTokenRequest', null, global); +goog.exportSymbol('proto.supervisor.GetTokenResponse', null, global); +goog.exportSymbol('proto.supervisor.ProvideTokenRequest', null, global); +goog.exportSymbol('proto.supervisor.ProvideTokenRequest.RegisterProvider', null, global); +goog.exportSymbol('proto.supervisor.ProvideTokenResponse', null, global); +goog.exportSymbol('proto.supervisor.SetTokenRequest', null, global); +goog.exportSymbol('proto.supervisor.SetTokenResponse', null, global); +goog.exportSymbol('proto.supervisor.TokenReuse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.GetTokenRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.supervisor.GetTokenRequest.repeatedFields_, null); +}; +goog.inherits(proto.supervisor.GetTokenRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.GetTokenRequest.displayName = 'proto.supervisor.GetTokenRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.GetTokenResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.supervisor.GetTokenResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.GetTokenResponse.displayName = 'proto.supervisor.GetTokenResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.SetTokenRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.supervisor.SetTokenRequest.repeatedFields_, null); +}; +goog.inherits(proto.supervisor.SetTokenRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.SetTokenRequest.displayName = 'proto.supervisor.SetTokenRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.SetTokenResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.supervisor.SetTokenResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.SetTokenResponse.displayName = 'proto.supervisor.SetTokenResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.ClearTokenRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.supervisor.ClearTokenRequest.oneofGroups_); +}; +goog.inherits(proto.supervisor.ClearTokenRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.ClearTokenRequest.displayName = 'proto.supervisor.ClearTokenRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.ClearTokenResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.supervisor.ClearTokenResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.ClearTokenResponse.displayName = 'proto.supervisor.ClearTokenResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.ProvideTokenRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.supervisor.ProvideTokenRequest.oneofGroups_); +}; +goog.inherits(proto.supervisor.ProvideTokenRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.ProvideTokenRequest.displayName = 'proto.supervisor.ProvideTokenRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.supervisor.ProvideTokenRequest.RegisterProvider, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.ProvideTokenRequest.RegisterProvider.displayName = 'proto.supervisor.ProvideTokenRequest.RegisterProvider'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.supervisor.ProvideTokenResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.supervisor.ProvideTokenResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.supervisor.ProvideTokenResponse.displayName = 'proto.supervisor.ProvideTokenResponse'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.supervisor.GetTokenRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.GetTokenRequest.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.GetTokenRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.GetTokenRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.GetTokenRequest.toObject = function(includeInstance, msg) { + var f, obj = { + host: jspb.Message.getFieldWithDefault(msg, 1, ""), + scopeList: jspb.Message.getRepeatedField(msg, 2), + description: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.GetTokenRequest} + */ +proto.supervisor.GetTokenRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.GetTokenRequest; + return proto.supervisor.GetTokenRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.GetTokenRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.GetTokenRequest} + */ +proto.supervisor.GetTokenRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setHost(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addScope(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setDescription(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.GetTokenRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.GetTokenRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.GetTokenRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.GetTokenRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHost(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getScopeList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = message.getDescription(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional string host = 1; + * @return {string} + */ +proto.supervisor.GetTokenRequest.prototype.getHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.supervisor.GetTokenRequest.prototype.setHost = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated string scope = 2; + * @return {!Array} + */ +proto.supervisor.GetTokenRequest.prototype.getScopeList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** @param {!Array} value */ +proto.supervisor.GetTokenRequest.prototype.setScopeList = function(value) { + jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + */ +proto.supervisor.GetTokenRequest.prototype.addScope = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + */ +proto.supervisor.GetTokenRequest.prototype.clearScopeList = function() { + this.setScopeList([]); +}; + + +/** + * optional string description = 3; + * @return {string} + */ +proto.supervisor.GetTokenRequest.prototype.getDescription = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.supervisor.GetTokenRequest.prototype.setDescription = function(value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.GetTokenResponse.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.GetTokenResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.GetTokenResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.GetTokenResponse.toObject = function(includeInstance, msg) { + var f, obj = { + token: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.GetTokenResponse} + */ +proto.supervisor.GetTokenResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.GetTokenResponse; + return proto.supervisor.GetTokenResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.GetTokenResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.GetTokenResponse} + */ +proto.supervisor.GetTokenResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setToken(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.GetTokenResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.GetTokenResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.GetTokenResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.GetTokenResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getToken(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string token = 1; + * @return {string} + */ +proto.supervisor.GetTokenResponse.prototype.getToken = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.supervisor.GetTokenResponse.prototype.setToken = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.supervisor.SetTokenRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.SetTokenRequest.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.SetTokenRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.SetTokenRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.SetTokenRequest.toObject = function(includeInstance, msg) { + var f, obj = { + host: jspb.Message.getFieldWithDefault(msg, 1, ""), + scopeList: jspb.Message.getRepeatedField(msg, 2), + token: jspb.Message.getFieldWithDefault(msg, 3, ""), + expiryDate: (f = msg.getExpiryDate()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + reuse: jspb.Message.getFieldWithDefault(msg, 5, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.SetTokenRequest} + */ +proto.supervisor.SetTokenRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.SetTokenRequest; + return proto.supervisor.SetTokenRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.SetTokenRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.SetTokenRequest} + */ +proto.supervisor.SetTokenRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setHost(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addScope(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setToken(value); + break; + case 4: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setExpiryDate(value); + break; + case 5: + var value = /** @type {!proto.supervisor.TokenReuse} */ (reader.readEnum()); + msg.setReuse(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.SetTokenRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.SetTokenRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.SetTokenRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.SetTokenRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHost(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getScopeList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = message.getToken(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getExpiryDate(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = message.getReuse(); + if (f !== 0.0) { + writer.writeEnum( + 5, + f + ); + } +}; + + +/** + * optional string host = 1; + * @return {string} + */ +proto.supervisor.SetTokenRequest.prototype.getHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.supervisor.SetTokenRequest.prototype.setHost = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated string scope = 2; + * @return {!Array} + */ +proto.supervisor.SetTokenRequest.prototype.getScopeList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** @param {!Array} value */ +proto.supervisor.SetTokenRequest.prototype.setScopeList = function(value) { + jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + */ +proto.supervisor.SetTokenRequest.prototype.addScope = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + */ +proto.supervisor.SetTokenRequest.prototype.clearScopeList = function() { + this.setScopeList([]); +}; + + +/** + * optional string token = 3; + * @return {string} + */ +proto.supervisor.SetTokenRequest.prototype.getToken = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.supervisor.SetTokenRequest.prototype.setToken = function(value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional google.protobuf.Timestamp expiry_date = 4; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.supervisor.SetTokenRequest.prototype.getExpiryDate = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 4)); +}; + + +/** @param {?proto.google.protobuf.Timestamp|undefined} value */ +proto.supervisor.SetTokenRequest.prototype.setExpiryDate = function(value) { + jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + */ +proto.supervisor.SetTokenRequest.prototype.clearExpiryDate = function() { + this.setExpiryDate(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.SetTokenRequest.prototype.hasExpiryDate = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional TokenReuse reuse = 5; + * @return {!proto.supervisor.TokenReuse} + */ +proto.supervisor.SetTokenRequest.prototype.getReuse = function() { + return /** @type {!proto.supervisor.TokenReuse} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** @param {!proto.supervisor.TokenReuse} value */ +proto.supervisor.SetTokenRequest.prototype.setReuse = function(value) { + jspb.Message.setProto3EnumField(this, 5, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.SetTokenResponse.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.SetTokenResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.SetTokenResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.SetTokenResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.SetTokenResponse} + */ +proto.supervisor.SetTokenResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.SetTokenResponse; + return proto.supervisor.SetTokenResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.SetTokenResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.SetTokenResponse} + */ +proto.supervisor.SetTokenResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.SetTokenResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.SetTokenResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.SetTokenResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.SetTokenResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.supervisor.ClearTokenRequest.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.supervisor.ClearTokenRequest.TokenCase = { + TOKEN_NOT_SET: 0, + VALUE: 1, + ALL: 2 +}; + +/** + * @return {proto.supervisor.ClearTokenRequest.TokenCase} + */ +proto.supervisor.ClearTokenRequest.prototype.getTokenCase = function() { + return /** @type {proto.supervisor.ClearTokenRequest.TokenCase} */(jspb.Message.computeOneofCase(this, proto.supervisor.ClearTokenRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.ClearTokenRequest.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.ClearTokenRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.ClearTokenRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ClearTokenRequest.toObject = function(includeInstance, msg) { + var f, obj = { + value: jspb.Message.getFieldWithDefault(msg, 1, ""), + all: jspb.Message.getFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.ClearTokenRequest} + */ +proto.supervisor.ClearTokenRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.ClearTokenRequest; + return proto.supervisor.ClearTokenRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.ClearTokenRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.ClearTokenRequest} + */ +proto.supervisor.ClearTokenRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setValue(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAll(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.ClearTokenRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.ClearTokenRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.ClearTokenRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ClearTokenRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional string value = 1; + * @return {string} + */ +proto.supervisor.ClearTokenRequest.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.supervisor.ClearTokenRequest.prototype.setValue = function(value) { + jspb.Message.setOneofField(this, 1, proto.supervisor.ClearTokenRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + */ +proto.supervisor.ClearTokenRequest.prototype.clearValue = function() { + jspb.Message.setOneofField(this, 1, proto.supervisor.ClearTokenRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.ClearTokenRequest.prototype.hasValue = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bool all = 2; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.supervisor.ClearTokenRequest.prototype.getAll = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 2, false)); +}; + + +/** @param {boolean} value */ +proto.supervisor.ClearTokenRequest.prototype.setAll = function(value) { + jspb.Message.setOneofField(this, 2, proto.supervisor.ClearTokenRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + */ +proto.supervisor.ClearTokenRequest.prototype.clearAll = function() { + jspb.Message.setOneofField(this, 2, proto.supervisor.ClearTokenRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.ClearTokenRequest.prototype.hasAll = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.ClearTokenResponse.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.ClearTokenResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.ClearTokenResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ClearTokenResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.ClearTokenResponse} + */ +proto.supervisor.ClearTokenResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.ClearTokenResponse; + return proto.supervisor.ClearTokenResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.ClearTokenResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.ClearTokenResponse} + */ +proto.supervisor.ClearTokenResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.ClearTokenResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.ClearTokenResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.ClearTokenResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ClearTokenResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.supervisor.ProvideTokenRequest.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.supervisor.ProvideTokenRequest.MessageCase = { + MESSAGE_NOT_SET: 0, + REGISTRATION: 1, + ANSWER: 2 +}; + +/** + * @return {proto.supervisor.ProvideTokenRequest.MessageCase} + */ +proto.supervisor.ProvideTokenRequest.prototype.getMessageCase = function() { + return /** @type {proto.supervisor.ProvideTokenRequest.MessageCase} */(jspb.Message.computeOneofCase(this, proto.supervisor.ProvideTokenRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.ProvideTokenRequest.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.ProvideTokenRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.ProvideTokenRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenRequest.toObject = function(includeInstance, msg) { + var f, obj = { + registration: (f = msg.getRegistration()) && proto.supervisor.ProvideTokenRequest.RegisterProvider.toObject(includeInstance, f), + answer: (f = msg.getAnswer()) && proto.supervisor.SetTokenRequest.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.ProvideTokenRequest} + */ +proto.supervisor.ProvideTokenRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.ProvideTokenRequest; + return proto.supervisor.ProvideTokenRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.ProvideTokenRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.ProvideTokenRequest} + */ +proto.supervisor.ProvideTokenRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.supervisor.ProvideTokenRequest.RegisterProvider; + reader.readMessage(value,proto.supervisor.ProvideTokenRequest.RegisterProvider.deserializeBinaryFromReader); + msg.setRegistration(value); + break; + case 2: + var value = new proto.supervisor.SetTokenRequest; + reader.readMessage(value,proto.supervisor.SetTokenRequest.deserializeBinaryFromReader); + msg.setAnswer(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.ProvideTokenRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.ProvideTokenRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.ProvideTokenRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRegistration(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.supervisor.ProvideTokenRequest.RegisterProvider.serializeBinaryToWriter + ); + } + f = message.getAnswer(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.supervisor.SetTokenRequest.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.ProvideTokenRequest.RegisterProvider.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.ProvideTokenRequest.RegisterProvider} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.toObject = function(includeInstance, msg) { + var f, obj = { + host: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.ProvideTokenRequest.RegisterProvider} + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.ProvideTokenRequest.RegisterProvider; + return proto.supervisor.ProvideTokenRequest.RegisterProvider.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.ProvideTokenRequest.RegisterProvider} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.ProvideTokenRequest.RegisterProvider} + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setHost(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.ProvideTokenRequest.RegisterProvider.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.ProvideTokenRequest.RegisterProvider} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHost(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string host = 1; + * @return {string} + */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.prototype.getHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.supervisor.ProvideTokenRequest.RegisterProvider.prototype.setHost = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional RegisterProvider registration = 1; + * @return {?proto.supervisor.ProvideTokenRequest.RegisterProvider} + */ +proto.supervisor.ProvideTokenRequest.prototype.getRegistration = function() { + return /** @type{?proto.supervisor.ProvideTokenRequest.RegisterProvider} */ ( + jspb.Message.getWrapperField(this, proto.supervisor.ProvideTokenRequest.RegisterProvider, 1)); +}; + + +/** @param {?proto.supervisor.ProvideTokenRequest.RegisterProvider|undefined} value */ +proto.supervisor.ProvideTokenRequest.prototype.setRegistration = function(value) { + jspb.Message.setOneofWrapperField(this, 1, proto.supervisor.ProvideTokenRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + */ +proto.supervisor.ProvideTokenRequest.prototype.clearRegistration = function() { + this.setRegistration(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.ProvideTokenRequest.prototype.hasRegistration = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional SetTokenRequest answer = 2; + * @return {?proto.supervisor.SetTokenRequest} + */ +proto.supervisor.ProvideTokenRequest.prototype.getAnswer = function() { + return /** @type{?proto.supervisor.SetTokenRequest} */ ( + jspb.Message.getWrapperField(this, proto.supervisor.SetTokenRequest, 2)); +}; + + +/** @param {?proto.supervisor.SetTokenRequest|undefined} value */ +proto.supervisor.ProvideTokenRequest.prototype.setAnswer = function(value) { + jspb.Message.setOneofWrapperField(this, 2, proto.supervisor.ProvideTokenRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + */ +proto.supervisor.ProvideTokenRequest.prototype.clearAnswer = function() { + this.setAnswer(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.ProvideTokenRequest.prototype.hasAnswer = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.supervisor.ProvideTokenResponse.prototype.toObject = function(opt_includeInstance) { + return proto.supervisor.ProvideTokenResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.supervisor.ProvideTokenResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenResponse.toObject = function(includeInstance, msg) { + var f, obj = { + request: (f = msg.getRequest()) && proto.supervisor.GetTokenRequest.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.supervisor.ProvideTokenResponse} + */ +proto.supervisor.ProvideTokenResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.supervisor.ProvideTokenResponse; + return proto.supervisor.ProvideTokenResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.supervisor.ProvideTokenResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.supervisor.ProvideTokenResponse} + */ +proto.supervisor.ProvideTokenResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.supervisor.GetTokenRequest; + reader.readMessage(value,proto.supervisor.GetTokenRequest.deserializeBinaryFromReader); + msg.setRequest(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.supervisor.ProvideTokenResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.supervisor.ProvideTokenResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.supervisor.ProvideTokenResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.supervisor.ProvideTokenResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRequest(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.supervisor.GetTokenRequest.serializeBinaryToWriter + ); + } +}; + + +/** + * optional GetTokenRequest request = 1; + * @return {?proto.supervisor.GetTokenRequest} + */ +proto.supervisor.ProvideTokenResponse.prototype.getRequest = function() { + return /** @type{?proto.supervisor.GetTokenRequest} */ ( + jspb.Message.getWrapperField(this, proto.supervisor.GetTokenRequest, 1)); +}; + + +/** @param {?proto.supervisor.GetTokenRequest|undefined} value */ +proto.supervisor.ProvideTokenResponse.prototype.setRequest = function(value) { + jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + */ +proto.supervisor.ProvideTokenResponse.prototype.clearRequest = function() { + this.setRequest(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.supervisor.ProvideTokenResponse.prototype.hasRequest = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * @enum {number} + */ +proto.supervisor.TokenReuse = { + REUSE_NEVER: 0, + REUSE_EXACTLY: 1, + REUSE_WHEN_POSSIBLE: 2 +}; + +goog.object.extend(exports, proto.supervisor); diff --git a/components/supervisor/cmd/container-backup.go b/components/supervisor/cmd/container-backup.go index e8b7a46949f56a..0a4238ebdd76bd 100644 --- a/components/supervisor/cmd/container-backup.go +++ b/components/supervisor/cmd/container-backup.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/container-drop.go b/components/supervisor/cmd/container-drop.go index 5ba4d903999a8a..7f625efb012960 100644 --- a/components/supervisor/cmd/container-drop.go +++ b/components/supervisor/cmd/container-drop.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/container.go b/components/supervisor/cmd/container.go index 779d114e95372f..6af042d0876ae7 100644 --- a/components/supervisor/cmd/container.go +++ b/components/supervisor/cmd/container.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/run.go b/components/supervisor/cmd/run.go index 554701c364d847..5d91ed04d5633d 100644 --- a/components/supervisor/cmd/run.go +++ b/components/supervisor/cmd/run.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/terminal-attach.go b/components/supervisor/cmd/terminal-attach.go index b4cabeb768244f..a426c3fa420f7e 100644 --- a/components/supervisor/cmd/terminal-attach.go +++ b/components/supervisor/cmd/terminal-attach.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/terminal-list.go b/components/supervisor/cmd/terminal-list.go index b24fa568d40744..07453f2bfe8085 100644 --- a/components/supervisor/cmd/terminal-list.go +++ b/components/supervisor/cmd/terminal-list.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/terminal-new.go b/components/supervisor/cmd/terminal-new.go index d29c4766c26dd5..04a37ec90bbd17 100644 --- a/components/supervisor/cmd/terminal-new.go +++ b/components/supervisor/cmd/terminal-new.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/cmd/terminal.go b/components/supervisor/cmd/terminal.go index c2d42fd3749c66..1be45ed4aceda0 100644 --- a/components/supervisor/cmd/terminal.go +++ b/components/supervisor/cmd/terminal.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package cmd import ( diff --git a/components/supervisor/go.mod b/components/supervisor/go.mod index 62a693861fe282..fd07137399bf04 100644 --- a/components/supervisor/go.mod +++ b/components/supervisor/go.mod @@ -10,6 +10,7 @@ require ( github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000 github.com/gitpod-io/gitpod/supervisor/api v0.0.0-00010101000000-000000000000 github.com/gitpod-io/gitpod/ws-sync/api v0.0.0-00010101000000-000000000000 + github.com/golang/protobuf v1.4.2 github.com/google/go-cmp v0.5.1 github.com/google/uuid v1.0.0 github.com/grpc-ecosystem/grpc-gateway v1.14.8 diff --git a/components/supervisor/go.sum b/components/supervisor/go.sum index 29e2536fdb38c1..31969b98388729 100644 --- a/components/supervisor/go.sum +++ b/components/supervisor/go.sum @@ -7,7 +7,6 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.48.0/go.mod h1:gGOnoa/XMQYHAscREBlbdHduGchEaP9N0//OXdrPI/M= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= @@ -565,7 +564,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= diff --git a/components/supervisor/leeway.Dockerfile b/components/supervisor/leeway.Dockerfile index 2d9bf90bce5b5a..1bd635fe9aa311 100644 --- a/components/supervisor/leeway.Dockerfile +++ b/components/supervisor/leeway.Dockerfile @@ -1,3 +1,7 @@ +# Copyright (c) 2020 TypeFox GmbH. All rights reserved. +# Licensed under the GNU Affero General Public License (AGPL). +# See License-AGPL.txt in the project root for license information. + FROM scratch # BEWARE: This must be the first layer in the image, s.t. that blobserve diff --git a/components/supervisor/pkg/supervisor/config.go b/components/supervisor/pkg/supervisor/config.go index 8389aa13053a89..8a510baeef41d9 100644 --- a/components/supervisor/pkg/supervisor/config.go +++ b/components/supervisor/pkg/supervisor/config.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package supervisor import ( diff --git a/components/supervisor/pkg/supervisor/ports.go b/components/supervisor/pkg/supervisor/ports.go index 4d47a1571a7311..5b92efbb081112 100644 --- a/components/supervisor/pkg/supervisor/ports.go +++ b/components/supervisor/pkg/supervisor/ports.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package supervisor import ( diff --git a/components/supervisor/pkg/supervisor/ports_test.go b/components/supervisor/pkg/supervisor/ports_test.go index 682a1ff1e14ef0..efedee7fcaf2c4 100644 --- a/components/supervisor/pkg/supervisor/ports_test.go +++ b/components/supervisor/pkg/supervisor/ports_test.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package supervisor import ( diff --git a/components/supervisor/pkg/supervisor/services.go b/components/supervisor/pkg/supervisor/services.go index 9dc579dc3e44c5..9be381d228da4e 100644 --- a/components/supervisor/pkg/supervisor/services.go +++ b/components/supervisor/pkg/supervisor/services.go @@ -1,11 +1,19 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package supervisor import ( "context" + "sync" + "time" + "github.com/gitpod-io/gitpod/common-go/log" csapi "github.com/gitpod-io/gitpod/content-service/api" "github.com/gitpod-io/gitpod/supervisor/api" "github.com/gitpod-io/gitpod/supervisor/pkg/backup" + "github.com/golang/protobuf/ptypes" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" @@ -138,3 +146,307 @@ func (s *statusService) PortsStatus(req *api.PortsStatusRequest, srv api.StatusS } } } + +// RegistrableTokenService can register the token service +type RegistrableTokenService struct { + Service api.TokenServiceServer +} + +// RegisterGRPC registers a gRPC service +func (s *RegistrableTokenService) RegisterGRPC(srv *grpc.Server) { + api.RegisterTokenServiceServer(srv, s.Service) +} + +// RegisterREST registers a REST service +func (s *RegistrableTokenService) RegisterREST(mux *runtime.ServeMux, grpcEndpoint string) error { + return api.RegisterTokenServiceHandlerFromEndpoint(context.Background(), mux, grpcEndpoint, []grpc.DialOption{grpc.WithInsecure()}) +} + +// NewInMemoryTokenService produces a new InMemoryTokenService +func NewInMemoryTokenService() *InMemoryTokenService { + return &InMemoryTokenService{ + provider: make(map[string][]tokenProvider), + } +} + +type token struct { + Token string + Host string + Scope map[string]struct{} + ExpiryDate time.Time + Reuse api.TokenReuse +} + +type tokenProvider interface { + GetToken(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) +} + +// InMemoryTokenService provides an in-memory caching token service +type InMemoryTokenService struct { + token []*token + provider map[string][]tokenProvider + mu sync.RWMutex +} + +// GetToken returns a token for a host +func (s *InMemoryTokenService) GetToken(ctx context.Context, req *api.GetTokenRequest) (*api.GetTokenResponse, error) { + tkn, ok := s.getCachedTokenFor(req.Host, req.Scope) + if ok { + return &api.GetTokenResponse{Token: tkn}, nil + } + + s.mu.RLock() + prov := s.provider[req.Host] + s.mu.RUnlock() + for _, p := range prov { + tkn, err := p.GetToken(ctx, req) + if err != nil { + log.WithError(err).WithField("host", req.Host).Warn("cannot get token from registered provider") + continue + } + if tkn == nil { + log.WithField("host", req.Host).Warn("got no token from registered provider") + continue + } + + s.cacheToken(tkn) + return &api.GetTokenResponse{Token: tkn.Token}, nil + } + + return nil, status.Error(codes.NotFound, "no token available") +} + +func (s *InMemoryTokenService) getCachedTokenFor(host string, scopes []string) (tkn string, ok bool) { + s.mu.RLock() + defer s.mu.RUnlock() + + var res *token + for _, tkn := range s.token { + if tkn.Host != host { + continue + } + + if time.Now().After(tkn.ExpiryDate) { + continue + } + + if tkn.Reuse == api.TokenReuse_REUSE_NEVER { + continue + } + if tkn.Reuse == api.TokenReuse_REUSE_EXACTLY && len(tkn.Scope) != len(scopes) { + continue + } + + hasScopes := true + for _, scp := range scopes { + if _, ok := tkn.Scope[scp]; !ok { + hasScopes = false + break + } + } + if !hasScopes { + continue + } + + res = tkn + break + } + + if res == nil { + return "", false + } + return res.Token, true +} + +func (s *InMemoryTokenService) cacheToken(tkn *token) { + if tkn.Reuse == api.TokenReuse_REUSE_NEVER { + // we just don't cache non-reuse tokens + return + } + + s.mu.Lock() + defer s.mu.Unlock() + + s.token = append(s.token, tkn) + log.WithField("host", tkn.Host).WithField("scopes", tkn.Scope).Info("registered new token") +} + +func convertReceivedToken(req *api.SetTokenRequest) (tkn *token, err error) { + expiryDate, err := ptypes.Timestamp(req.GetExpiryDate()) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid expiry date: %q", err) + } + if time.Now().After(expiryDate) { + return nil, status.Error(codes.InvalidArgument, "invalid expiry date: already expired") + } + if req.Token == "" { + return nil, status.Error(codes.InvalidArgument, "token is required") + } + if req.Host == "" { + return nil, status.Error(codes.InvalidArgument, "host is required") + } + + return &token{ + Host: req.Host, + ExpiryDate: expiryDate, + Scope: mapScopes(req.Scope), + Token: req.Token, + Reuse: req.Reuse, + }, nil +} + +func mapScopes(s []string) map[string]struct{} { + scopes := make(map[string]struct{}, len(s)) + for _, scp := range s { + scopes[scp] = struct{}{} + } + return scopes +} + +// SetToken sets a token for a host +func (s *InMemoryTokenService) SetToken(ctx context.Context, req *api.SetTokenRequest) (*api.SetTokenResponse, error) { + tkn, err := convertReceivedToken(req) + if err != nil { + return nil, err + } + s.cacheToken(tkn) + + return &api.SetTokenResponse{}, nil +} + +// ClearToken clears previously cached tokens +func (s *InMemoryTokenService) ClearToken(ctx context.Context, req *api.ClearTokenRequest) (*api.ClearTokenResponse, error) { + if req.GetAll() { + s.mu.Lock() + defer s.mu.Unlock() + + s.token = nil + + log.Info("cleared all cached tokens") + return &api.ClearTokenResponse{}, nil + } + if tkn := req.GetValue(); tkn != "" { + s.mu.Lock() + defer s.mu.Unlock() + + var found bool + for i, t := range s.token { + if t.Token != tkn { + continue + } + + found = true + s.token = append(s.token[:i], s.token[i+1:]...) + log.WithField("host", t.Host).WithField("scopes", t.Scope).Info("cleared token") + break + } + if !found { + return nil, status.Error(codes.NotFound, "token not found") + } + + return &api.ClearTokenResponse{}, nil + } + + return nil, status.Error(codes.Unknown, "unknown operation") +} + +// ProvideToken registers a token provider +func (s *InMemoryTokenService) ProvideToken(srv api.TokenService_ProvideTokenServer) error { + req, err := srv.Recv() + if err != nil { + return err + } + + reg := req.GetRegistration() + if reg == nil { + return status.Error(codes.FailedPrecondition, "must register first") + } + if reg.Host == "" { + return status.Error(codes.InvalidArgument, "host is required") + } + + rt := &remoteTokenProvider{srv, make(chan *remoteTknReq)} + s.mu.Lock() + s.provider[reg.Host] = append(s.provider[reg.Host], rt) + s.mu.Unlock() + + err = rt.Serve() + + s.mu.Lock() + for i, p := range s.provider[reg.Host] { + if p == rt { + s.provider[reg.Host] = append(s.provider[reg.Host][:i], s.provider[reg.Host][i+1:]...) + } + } + s.mu.Unlock() + + return err +} + +type remoteTknReq struct { + Req *api.GetTokenRequest + Resp chan *token + Err chan error +} + +type remoteTokenProvider struct { + srv api.TokenService_ProvideTokenServer + inc chan *remoteTknReq +} + +func (rt *remoteTokenProvider) Serve() (err error) { + defer func() { + if err == nil { + return + } + log.WithError(err).Warn("token provider dropped out") + }() + + for { + req := <-rt.inc + + err := rt.srv.Send(&api.ProvideTokenResponse{Request: req.Req}) + if err != nil { + req.Err <- err + return err + } + + resp, err := rt.srv.Recv() + if err != nil { + req.Err <- err + return err + } + + answ := resp.GetAnswer() + if answ == nil { + err = status.Error(codes.InvalidArgument, "provider did not answer request") + req.Err <- err + return err + } + + tkn, err := convertReceivedToken(answ) + if err != nil { + req.Err <- err + return err + } + + req.Resp <- tkn + } +} + +func (rt *remoteTokenProvider) GetToken(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) { + rr := &remoteTknReq{ + Req: req, + Err: make(chan error, 1), + Resp: make(chan *token, 1), + } + rt.inc <- rr + + select { + case <-ctx.Done(): + return nil, status.Error(codes.DeadlineExceeded, ctx.Err().Error()) + case err = <-rr.Err: + case tkn = <-rr.Resp: + } + return +} diff --git a/components/supervisor/pkg/supervisor/services_test.go b/components/supervisor/pkg/supervisor/services_test.go new file mode 100644 index 00000000000000..72d889fa4bb09e --- /dev/null +++ b/components/supervisor/pkg/supervisor/services_test.go @@ -0,0 +1,314 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package supervisor + +import ( + "context" + "testing" + "time" + + "github.com/gitpod-io/gitpod/supervisor/api" + "github.com/golang/protobuf/ptypes" + "github.com/google/go-cmp/cmp" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestInMemoryTokenServiceGetToken(t *testing.T) { + type Expectation struct { + Resp *api.GetTokenResponse + Err string + } + var ( + defaultToken = "foobar" + defaultHost = "gitpod.io" + + errNoToken = status.Error(codes.NotFound, "no token available").Error() + ) + newToken := func(scopes ...string) *token { + return &token{ + Host: defaultHost, + ExpiryDate: time.Now().Add(1 * time.Hour), + Scope: mapScopes(scopes), + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + } + } + + tests := []struct { + Desc string + Req *api.GetTokenRequest + Cache []*token + Provider map[string][]tokenProvider + Expectation Expectation + }{ + { + Desc: "no provider", + Req: &api.GetTokenRequest{ + Host: defaultHost, + }, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "cached token (no reuse)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{ + func(t *token) *token { + t.Reuse = api.TokenReuse_REUSE_NEVER + return t + }(newToken("a1", "a2")), + }, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "cached token (exact, reuse when possible)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{newToken("a1", "a2")}, + Expectation: Expectation{ + Resp: &api.GetTokenResponse{Token: defaultToken}, + }, + }, + { + Desc: "cached token (expired)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{ + { + Host: defaultHost, + ExpiryDate: time.Now().Add(-2 * time.Hour), + Scope: mapScopes([]string{"a1", "a2"}), + Token: defaultToken, + }, + {Host: "foo." + defaultHost}, + }, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "cached token (fewer scopes)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{newToken("a1")}, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "cached token (more scopes, reuse when possible)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{newToken("a1", "a2", "a3")}, + Expectation: Expectation{ + Resp: &api.GetTokenResponse{Token: defaultToken}, + }, + }, + { + Desc: "cached token (more scopes, exact reuse)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Cache: []*token{ + func(t *token) *token { + t.Reuse = api.TokenReuse_REUSE_EXACTLY + return t + }(newToken("a1", "a2", "a3")), + }, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "token provider (no token)", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Provider: map[string][]tokenProvider{ + defaultHost: {tokenProviderFunc(func(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) { + return + })}, + }, + Expectation: Expectation{ + Err: errNoToken, + }, + }, + { + Desc: "token provider", + Req: &api.GetTokenRequest{ + Host: defaultHost, + Scope: []string{"a1", "a2"}, + }, + Provider: map[string][]tokenProvider{ + defaultHost: {tokenProviderFunc(func(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) { + return newToken("a1", "a2"), nil + })}, + }, + Expectation: Expectation{ + Resp: &api.GetTokenResponse{Token: defaultToken}, + }, + }, + } + + for _, test := range tests { + t.Run(test.Desc, func(t *testing.T) { + service := NewInMemoryTokenService() + service.token = test.Cache + service.provider = test.Provider + + resp, err := service.GetToken(context.Background(), test.Req) + + res := Expectation{ + Resp: resp, + } + if err != nil { + res.Err = err.Error() + } + + if diff := cmp.Diff(test.Expectation, res); diff != "" { + t.Errorf("unexpected status (-want +got):\n%s", diff) + } + }) + } +} + +func TestInMemoryTokenServiceSetToken(t *testing.T) { + var ( + defaultHost = "gitpod.io" + defaultToken = "foobar" + ) + + tExpired, _ := ptypes.TimestampProto(time.Now().Add(-2 * time.Hour)) + tValid, _ := ptypes.TimestampProto(time.Now().Add(2 * time.Hour)) + + type Expectation struct { + Err string + TokenCount int + } + tests := []struct { + Desc string + Req *api.SetTokenRequest + Expectation Expectation + }{ + { + Desc: "expired token", + Req: &api.SetTokenRequest{ + Host: defaultHost, + ExpiryDate: tExpired, + Scope: []string{}, + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + }, + Expectation: Expectation{ + Err: status.Error(codes.InvalidArgument, "invalid expiry date: already expired").Error(), + }, + }, + { + Desc: "missing token", + Req: &api.SetTokenRequest{ + Host: defaultHost, + ExpiryDate: tValid, + Scope: []string{}, + Token: "", + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + }, + Expectation: Expectation{ + Err: status.Error(codes.InvalidArgument, "token is required").Error(), + }, + }, + { + Desc: "missing host", + Req: &api.SetTokenRequest{ + Host: "", + ExpiryDate: tValid, + Scope: []string{}, + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + }, + Expectation: Expectation{ + Err: status.Error(codes.InvalidArgument, "host is required").Error(), + }, + }, + { + Desc: "no scopes", + Req: &api.SetTokenRequest{ + Host: defaultHost, + ExpiryDate: tValid, + Scope: []string{}, + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + }, + Expectation: Expectation{ + TokenCount: 1, + }, + }, + { + Desc: "with scopes", + Req: &api.SetTokenRequest{ + Host: defaultHost, + ExpiryDate: tValid, + Scope: []string{"a1"}, + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_WHEN_POSSIBLE, + }, + Expectation: Expectation{ + TokenCount: 1, + }, + }, + { + Desc: "no reuse", + Req: &api.SetTokenRequest{ + Host: defaultHost, + ExpiryDate: tValid, + Scope: []string{"a1"}, + Token: defaultToken, + Reuse: api.TokenReuse_REUSE_NEVER, + }, + Expectation: Expectation{ + TokenCount: 0, + }, + }, + } + + for _, test := range tests { + t.Run(test.Desc, func(t *testing.T) { + service := NewInMemoryTokenService() + _, err := service.SetToken(context.Background(), test.Req) + res := Expectation{ + TokenCount: len(service.token), + } + if err != nil { + res.Err = err.Error() + } + + if diff := cmp.Diff(test.Expectation, res); diff != "" { + t.Errorf("unexpected status (-want +got):\n%s", diff) + } + }) + } +} + +type tokenProviderFunc func(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) + +func (f tokenProviderFunc) GetToken(ctx context.Context, req *api.GetTokenRequest) (tkn *token, err error) { + return f(ctx, req) +} diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 0ebfbf59608ff1..abcf0e3e975b93 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -120,6 +120,7 @@ func Run(options ...RunOption) { IDEReady: ideReady, }) apiServices = append(apiServices, termMuxSrv) + apiServices = append(apiServices, &RegistrableTokenService{NewInMemoryTokenService()}) apiServices = append(apiServices, opts.AdditionalServices...) var wg sync.WaitGroup diff --git a/components/supervisor/pkg/terminal/service.go b/components/supervisor/pkg/terminal/service.go index 439950d16f9d05..0b46ced912f912 100644 --- a/components/supervisor/pkg/terminal/service.go +++ b/components/supervisor/pkg/terminal/service.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package terminal import ( diff --git a/components/supervisor/pkg/terminal/terminal.go b/components/supervisor/pkg/terminal/terminal.go index bce92dda8d7f9a..76b75c78419903 100644 --- a/components/supervisor/pkg/terminal/terminal.go +++ b/components/supervisor/pkg/terminal/terminal.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 TypeFox GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + package terminal import ( diff --git a/components/theia/packages/gitpod-extension/src/node/supervisor-client-provider.ts b/components/theia/packages/gitpod-extension/src/node/supervisor-client-provider.ts index 3cef101c8e8f07..3f672f174c4667 100644 --- a/components/theia/packages/gitpod-extension/src/node/supervisor-client-provider.ts +++ b/components/theia/packages/gitpod-extension/src/node/supervisor-client-provider.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + import { injectable } from "inversify"; import { IStatusServiceClient, StatusServiceClient } from "@gitpod/supervisor/lib/status_grpc_pb"; import * as grpc from "@grpc/grpc-js"; diff --git a/components/theia/packages/gitpod-extension/src/node/supervisor-serverd-ports-service.ts b/components/theia/packages/gitpod-extension/src/node/supervisor-serverd-ports-service.ts index 63d89328b42b3b..cfaeea8fab4d0b 100644 --- a/components/theia/packages/gitpod-extension/src/node/supervisor-serverd-ports-service.ts +++ b/components/theia/packages/gitpod-extension/src/node/supervisor-serverd-ports-service.ts @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2020 TypeFox GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + import { inject, injectable, postConstruct } from "inversify"; import { ServedPortsServiceServer, ServedPort, ServedPortsServiceClient, ServedPortsChangeEvent } from "src/common/served-ports-service"; import { SupervisorClientProvider } from "./supervisor-client-provider";