include full license key in RPC

This commit is contained in:
Robert Lin 2024-08-09 18:27:01 -07:00
parent 78afd321cf
commit f15b76fac2
4 changed files with 58 additions and 38 deletions

View File

@ -25,8 +25,16 @@ type CheckLicenseKeyRequest struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The signed license key to validate. For backwards compatibility, this
// currently also accepts a token of the format 'slk_$hex($sha256(licenseKey))',
// but this is deprecated and will be removed in Sourcegraph 5.8 onwards.
//
// Required.
LicenseKey string `protobuf:"bytes,1,opt,name=license_key,json=licenseKey,proto3" json:"license_key,omitempty"`
// Self-reported Sourcegraph instance identifier (also known as 'site ID').
InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
//
// Required.
InstanceId string `protobuf:"bytes,2,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
}
func (x *CheckLicenseKeyRequest) Reset() {
@ -61,6 +69,13 @@ func (*CheckLicenseKeyRequest) Descriptor() ([]byte, []int) {
return file_subscriptionlicensechecks_proto_rawDescGZIP(), []int{0}
}
func (x *CheckLicenseKeyRequest) GetLicenseKey() string {
if x != nil {
return x.LicenseKey
}
return ""
}
func (x *CheckLicenseKeyRequest) GetInstanceId() string {
if x != nil {
return x.InstanceId
@ -133,33 +148,35 @@ var file_subscriptionlicensechecks_proto_rawDesc = []byte{
0x6f, 0x12, 0x2d, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x61, 0x6c, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2e, 0x76, 0x31,
0x22, 0x39, 0x0a, 0x16, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,
0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e,
0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x17, 0x43,
0x22, 0x5a, 0x0a, 0x16, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,
0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69,
0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x69,
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x17,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72,
0x65, 0x61, 0x73, 0x6f, 0x6e, 0x32, 0xc7, 0x01, 0x0a, 0x20, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x43, 0x68, 0x65,
0x63, 0x6b, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa2, 0x01, 0x0a, 0x0f, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x45,
0x2e, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x61,
0x6c, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69,
0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06,
0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65,
0x61, 0x73, 0x6f, 0x6e, 0x32, 0xc7, 0x01, 0x0a, 0x20, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa2, 0x01, 0x0a, 0x0f, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x45, 0x2e,
0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c,
0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x63,
0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73,
0x65, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65, 0x63, 0x6b,
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73,
0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x56,
0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67,
0x72, 0x61, 0x70, 0x68, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72,
0x69, 0x73, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65,
0x63, 0x6b, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69,
0x73, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68, 0x65, 0x63,
0x6b, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4c, 0x69, 0x63, 0x65, 0x6e,
0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x70,
0x72, 0x69, 0x73, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x63, 0x68,
0x65, 0x63, 0x6b, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -10,14 +10,21 @@ option go_package = "github.com/sourcegraph/sourcegraph/lib/enterpriseportal/sub
// Product implementations can use these endpoints to verify the status of a
// license.
service SubscriptionLicenseChecksService {
// CheckLicenseKey returns the status of a license key. It expects bearer
// authorization with a token of the format 'slk_$hex($sha256(licenseKey))'.
// CheckLicenseKey returns the status of a license key.
rpc CheckLicenseKey(CheckLicenseKeyRequest) returns (CheckLicenseKeyResponse) {}
}
message CheckLicenseKeyRequest {
// The signed license key to validate. For backwards compatibility, this
// currently also accepts a token of the format 'slk_$hex($sha256(licenseKey))',
// but this is deprecated and will be removed in Sourcegraph 5.8 onwards.
//
// Required.
string license_key = 1;
// Self-reported Sourcegraph instance identifier (also known as 'site ID').
string instance_id = 1;
//
// Required.
string instance_id = 2;
}
message CheckLicenseKeyResponse {

View File

@ -26,8 +26,7 @@ const (
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SubscriptionLicenseChecksServiceClient interface {
// CheckLicenseKey returns the status of a license key. It expects bearer
// authorization with a token of the format 'slk_$hex($sha256(licenseKey))'.
// CheckLicenseKey returns the status of a license key.
CheckLicenseKey(ctx context.Context, in *CheckLicenseKeyRequest, opts ...grpc.CallOption) (*CheckLicenseKeyResponse, error)
}
@ -52,8 +51,7 @@ func (c *subscriptionLicenseChecksServiceClient) CheckLicenseKey(ctx context.Con
// All implementations must embed UnimplementedSubscriptionLicenseChecksServiceServer
// for forward compatibility
type SubscriptionLicenseChecksServiceServer interface {
// CheckLicenseKey returns the status of a license key. It expects bearer
// authorization with a token of the format 'slk_$hex($sha256(licenseKey))'.
// CheckLicenseKey returns the status of a license key.
CheckLicenseKey(context.Context, *CheckLicenseKeyRequest) (*CheckLicenseKeyResponse, error)
mustEmbedUnimplementedSubscriptionLicenseChecksServiceServer()
}

View File

@ -48,8 +48,7 @@ var (
// SubscriptionLicenseChecksServiceClient is a client for the
// enterpriseportal.subscriptionlicensechecks.v1.SubscriptionLicenseChecksService service.
type SubscriptionLicenseChecksServiceClient interface {
// CheckLicenseKey returns the status of a license key. It expects bearer
// authorization with a token of the format 'slk_$hex($sha256(licenseKey))'.
// CheckLicenseKey returns the status of a license key.
CheckLicenseKey(context.Context, *connect.Request[v1.CheckLicenseKeyRequest]) (*connect.Response[v1.CheckLicenseKeyResponse], error)
}
@ -87,8 +86,7 @@ func (c *subscriptionLicenseChecksServiceClient) CheckLicenseKey(ctx context.Con
// SubscriptionLicenseChecksServiceHandler is an implementation of the
// enterpriseportal.subscriptionlicensechecks.v1.SubscriptionLicenseChecksService service.
type SubscriptionLicenseChecksServiceHandler interface {
// CheckLicenseKey returns the status of a license key. It expects bearer
// authorization with a token of the format 'slk_$hex($sha256(licenseKey))'.
// CheckLicenseKey returns the status of a license key.
CheckLicenseKey(context.Context, *connect.Request[v1.CheckLicenseKeyRequest]) (*connect.Response[v1.CheckLicenseKeyResponse], error)
}