Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aabb697
Update kotskinds dependency to support v1beta2 License API
crdant Oct 23, 2025
26f3ba0
Add LicenseWrapper type to abstract v1beta1/v1beta2 differences
crdant Oct 23, 2025
41658b5
Update license loading and storage to use LicenseWrapper
crdant Oct 23, 2025
6d6a110
Adds SHA-256 signature verification for v1beta2 licenses
crdant Oct 23, 2025
ab318a2
Refactor codebase to use LicenseWrapper throughout
crdant Oct 23, 2025
fc96340
Updates pact contract tests to use LicenseWrapper
crdant Oct 23, 2025
ebe3c57
Update v1beta2 license signature handling to match backend
crdant Oct 24, 2025
b1f1792
Fix entitlement signature verification to match vandoor format
crdant Oct 24, 2025
964bd71
Update kotskinds dependency to get ValidateLicense methods
crdant Oct 27, 2025
0e12cb9
Migrate license validation to use kotskinds ValidateLicense
crdant Oct 27, 2025
9a2be7a
Bump chart version to 1.10.0
crdant Oct 27, 2025
fa1153b
Restores version placeholder
crdant Oct 27, 2025
0d146b1
Add v2 signature field to LicenseFieldSignature for v1beta2 support
crdant Oct 28, 2025
d7b42b7
Merge branch 'main' into feature/crdant/adds-license-v1beta2-support
crdant Oct 29, 2025
06dffc6
Migrate replicated-sdk to use kotskinds/pkg/licensewrapper
crdant Oct 28, 2025
cf65c51
Update kotskinds dependency to commit 174e89c9 for EntitlementFieldWr…
crdant Oct 29, 2025
6568419
Refactor LicenseIsExpired() to use EntitlementFieldWrapper
crdant Oct 29, 2025
b65254b
Refactor licenseInfoFromWrapper() to use EntitlementFieldWrapper
crdant Oct 29, 2025
8316e2f
Fix test imports to use licensewrapper from kotskinds
crdant Oct 29, 2025
f739ea5
Use unified entitlements field with EntitlementFieldWrapper
crdant Oct 29, 2025
9721d11
Fix entitlements JSON serialization to use EntitlementField not wrapper
crdant Oct 29, 2025
03386a6
Fix: Return version-specific EntitlementField in API response
crdant Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/replicatedhq/replicated-sdk

go 1.24.0
go 1.24.6

require (
github.com/blang/semver v3.5.1+incompatible
Expand All @@ -11,7 +11,7 @@ require (
github.com/pact-foundation/pact-go v1.10.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe
github.com/replicatedhq/kotskinds v0.0.0-20251029124314-174e89c93554
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/cobra v1.10.1
github.com/spf13/pflag v1.0.10
Expand Down Expand Up @@ -127,7 +127,7 @@ require (
golang.org/x/time v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/grpc v1.72.1 // indirect
google.golang.org/protobuf v1.36.5 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
Expand Down Expand Up @@ -324,8 +324,8 @@ github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb
github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ=
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe h1:3AJInd06UxzqHmgy8+24CPsT2tYSE0zToJZyuX9q+MA=
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe/go.mod h1:QjhIUu3+OmHZ09u09j3FCoTt8F3BYtQglS+OLmftu9I=
github.com/replicatedhq/kotskinds v0.0.0-20251029124314-174e89c93554 h1:a9vLewcXgVC/vclEak7CV0gsSYhYinjnWDoUkzrqN4w=
github.com/replicatedhq/kotskinds v0.0.0-20251029124314-174e89c93554/go.mod h1:+k4PHo2wukoU9kdiKrqqgi89Wmj+9AiwppYGVK11zig=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down Expand Up @@ -550,8 +550,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
3 changes: 2 additions & 1 deletion pact/custom_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
"github.com/replicatedhq/replicated-sdk/pkg/handlers"
"github.com/replicatedhq/replicated-sdk/pkg/k8sutil"
licensewrapper "github.com/replicatedhq/kotskinds/pkg/licensewrapper"
"github.com/replicatedhq/replicated-sdk/pkg/store"
"github.com/replicatedhq/replicated-sdk/pkg/util"
"k8s.io/client-go/kubernetes/fake"
Expand Down Expand Up @@ -75,7 +76,7 @@ func TestSendCustomAppMetrics(t *testing.T) {
pactInteraction()

storeOptions := store.InitInMemoryStoreOptions{
License: license,
License: licensewrapper.LicenseWrapper{V1: license},
LicenseFields: nil,
ReplicatedAppEndpoint: license.Spec.Endpoint,
ChannelID: license.Spec.ChannelID,
Expand Down
17 changes: 9 additions & 8 deletions pact/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
appstatetypes "github.com/replicatedhq/replicated-sdk/pkg/appstate/types"
"github.com/replicatedhq/replicated-sdk/pkg/k8sutil"
licensewrapper "github.com/replicatedhq/kotskinds/pkg/licensewrapper"
"github.com/replicatedhq/replicated-sdk/pkg/report"
mock_store "github.com/replicatedhq/replicated-sdk/pkg/store/mock"
"github.com/replicatedhq/replicated-sdk/pkg/util"
Expand Down Expand Up @@ -39,12 +40,12 @@ func TestSendInstanceData(t *testing.T) {
{
name: "successful instance data request",
mockStoreExpectations: func() {
mockStore.EXPECT().GetLicense().Return(&v1beta1.License{
mockStore.EXPECT().GetLicense().Return(licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-instance-customer-0-license",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
})
}})
mockStore.EXPECT().GetNamespace().Times(2).Return("replicated-sdk-instance-namespace")
mockStore.EXPECT().GetReplicatedID().Return("replicated-sdk-instance-cluster-id")
mockStore.EXPECT().GetAppID().Return("replicated-sdk-instance-app")
Expand Down Expand Up @@ -91,12 +92,12 @@ func TestSendInstanceData(t *testing.T) {
{
name: "expired license should return error",
mockStoreExpectations: func() {
mockStore.EXPECT().GetLicense().Return(&v1beta1.License{
mockStore.EXPECT().GetLicense().Return(licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-instance-customer-2-license",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
})
}})
mockStore.EXPECT().GetNamespace().Times(2).Return("replicated-sdk-instance-namespace")
mockStore.EXPECT().GetReplicatedID().Return("replicated-sdk-instance-cluster-id")
mockStore.EXPECT().GetAppID().Return("replicated-sdk-instance-app")
Expand Down Expand Up @@ -143,12 +144,12 @@ func TestSendInstanceData(t *testing.T) {
{
name: "nonexistent license should return error",
mockStoreExpectations: func() {
mockStore.EXPECT().GetLicense().Return(&v1beta1.License{
mockStore.EXPECT().GetLicense().Return(licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-instance-customer-nonexistent-license",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
})
}})
mockStore.EXPECT().GetNamespace().Times(2).Return("replicated-sdk-instance-namespace")
mockStore.EXPECT().GetReplicatedID().Return("replicated-sdk-instance-cluster-id")
mockStore.EXPECT().GetAppID().Return("replicated-sdk-instance-app")
Expand Down Expand Up @@ -195,12 +196,12 @@ func TestSendInstanceData(t *testing.T) {
{
name: "unauthenticated instance data request should return error",
mockStoreExpectations: func() {
mockStore.EXPECT().GetLicense().Return(&v1beta1.License{
mockStore.EXPECT().GetLicense().Return(licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-instance-customer-0-license",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
})
}})
mockStore.EXPECT().GetNamespace().Times(2).Return("replicated-sdk-instance-namespace")
mockStore.EXPECT().GetReplicatedID().Return("replicated-sdk-instance-cluster-id")
mockStore.EXPECT().GetAppID().Return("replicated-sdk-instance-app")
Expand Down
19 changes: 10 additions & 9 deletions pact/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/pact-foundation/pact-go/dsl"
"github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
licensewrapper "github.com/replicatedhq/kotskinds/pkg/licensewrapper"
"github.com/replicatedhq/replicated-sdk/pkg/license"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func TestGetLatestLicense(t *testing.T) {
// }

type args struct {
license *v1beta1.License
license licensewrapper.LicenseWrapper
endpoint string
}
tests := []struct {
Expand Down Expand Up @@ -96,13 +97,13 @@ func TestGetLatestLicense(t *testing.T) {
{
name: "no license found",
args: args{
license: &v1beta1.License{
license: licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "not-a-customer-license",
AppSlug: "replicated-sdk-license-app",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
},
}},
},
pactInteraction: func() {
pact.
Expand All @@ -126,13 +127,13 @@ func TestGetLatestLicense(t *testing.T) {
{
name: "no app found",
args: args{
license: &v1beta1.License{
license: licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-license-customer-0-license",
AppSlug: "not-an-app",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
},
}},
},
pactInteraction: func() {
pact.
Expand All @@ -156,13 +157,13 @@ func TestGetLatestLicense(t *testing.T) {
{
name: "license is not for this app",
args: args{
license: &v1beta1.License{
license: licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-license-customer-0-license",
AppSlug: "replicated-sdk-instance-app",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
},
}},
},
pactInteraction: func() {
pact.
Expand All @@ -187,13 +188,13 @@ func TestGetLatestLicense(t *testing.T) {
{
name: "license is archived",
args: args{
license: &v1beta1.License{
license: licensewrapper.LicenseWrapper{V1: &v1beta1.License{
Spec: v1beta1.LicenseSpec{
LicenseID: "replicated-sdk-license-customer-archived-license",
AppSlug: "replicated-sdk-license-app",
Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
},
},
}},
},
pactInteraction: func() {
pact.
Expand Down
28 changes: 14 additions & 14 deletions pkg/apiserver/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/cenkalti/backoff/v4"
"github.com/pkg/errors"
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
licensewrapper "github.com/replicatedhq/kotskinds/pkg/licensewrapper"
"github.com/replicatedhq/replicated-sdk/pkg/appstate"
appstatetypes "github.com/replicatedhq/replicated-sdk/pkg/appstate/types"
"github.com/replicatedhq/replicated-sdk/pkg/heartbeat"
Expand Down Expand Up @@ -56,40 +56,40 @@ func bootstrap(params APIServerParams) error {
}
}

var unverifiedLicense *kotsv1beta1.License
var unverifiedWrapper licensewrapper.LicenseWrapper
if len(params.LicenseBytes) > 0 {
l, err := sdklicense.LoadLicenseFromBytes(params.LicenseBytes)
wrapper, err := sdklicense.LoadLicenseFromBytes(params.LicenseBytes)
if err != nil {
return errors.Wrap(err, "failed to parse license from base64")
}
unverifiedLicense = l
unverifiedWrapper = wrapper
} else if params.IntegrationLicenseID != "" {
l, err := sdklicense.GetLicenseByID(params.IntegrationLicenseID, params.ReplicatedAppEndpoint)
wrapper, err := sdklicense.GetLicenseByID(params.IntegrationLicenseID, params.ReplicatedAppEndpoint)
if err != nil {
return backoff.Permanent(errors.Wrap(err, "failed to get license by id for integration license id"))
}
if l.Spec.LicenseType != "dev" {
if wrapper.GetLicenseType() != "dev" {
return errors.New("integration license must be a dev license")
}
unverifiedLicense = l
unverifiedWrapper = wrapper
}

verifiedLicense, err := sdklicense.VerifySignature(unverifiedLicense)
verifiedWrapper, err := sdklicense.VerifySignature(unverifiedWrapper)
if err != nil {
return backoff.Permanent(errors.Wrap(err, "failed to verify license signature"))
}

if !util.IsAirgap() {
// sync license
licenseData, err := sdklicense.GetLatestLicense(verifiedLicense, params.ReplicatedAppEndpoint)
licenseData, err := sdklicense.GetLatestLicense(verifiedWrapper, params.ReplicatedAppEndpoint)
if err != nil {
return errors.Wrap(err, "failed to get latest license")
}
verifiedLicense = licenseData.License
verifiedWrapper = licenseData.License
}

// check license expiration
expired, err := sdklicense.LicenseIsExpired(verifiedLicense)
expired, err := sdklicense.LicenseIsExpired(verifiedWrapper)
if err != nil {
return errors.Wrap(err, "failed to check if license is expired")
}
Expand All @@ -99,16 +99,16 @@ func bootstrap(params APIServerParams) error {

channelID := params.ChannelID
if channelID == "" {
channelID = verifiedLicense.Spec.ChannelID
channelID = verifiedWrapper.GetChannelID()
}

channelName := params.ChannelName
if channelName == "" {
channelName = verifiedLicense.Spec.ChannelName
channelName = verifiedWrapper.GetChannelName()
}

store.InitInMemory(store.InitInMemoryStoreOptions{
License: verifiedLicense,
License: verifiedWrapper,
LicenseFields: params.LicenseFields,
AppName: params.AppName,
ChannelID: channelID,
Expand Down
Loading