From c447826fa0f38557f603aae6bb66e61afeaff442 Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Tue, 17 May 2022 16:07:34 +0000 Subject: [PATCH] [licensor] allow invalid domain in professional license --- components/licensor/ee/pkg/licensor/licensor.go | 2 ++ components/licensor/ee/pkg/licensor/licensor_test.go | 4 ++-- components/licensor/ee/pkg/licensor/replicated.go | 10 +++------- components/licensor/typescript/ee/main.go | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/components/licensor/ee/pkg/licensor/licensor.go b/components/licensor/ee/pkg/licensor/licensor.go index 4ec9b1b298de37..1b05a57d094643 100644 --- a/components/licensor/ee/pkg/licensor/licensor.go +++ b/components/licensor/ee/pkg/licensor/licensor.go @@ -150,6 +150,8 @@ var defaultLicense = LicensePayload{ // Domain, ValidUntil are free for all } +// we match domains only for `gitpod` license and not with replicated license. +// In the case of replicated this ensures faster client onboarding func matchesDomain(pattern, domain string) bool { if pattern == "" { return true diff --git a/components/licensor/ee/pkg/licensor/licensor_test.go b/components/licensor/ee/pkg/licensor/licensor_test.go index eec2696e28d2e2..371ae7cc8461aa 100644 --- a/components/licensor/ee/pkg/licensor/licensor_test.go +++ b/components/licensor/ee/pkg/licensor/licensor_test.go @@ -126,9 +126,9 @@ func (test *licenseTest) Run(t *testing.T) { }) if test.License == nil { - eval = newReplicatedEvaluator(client, domain) + eval = newReplicatedEvaluator(client) } else { - eval = newReplicatedEvaluator(client, test.License.Domain) + eval = newReplicatedEvaluator(client) } } else { t.Fatalf("unknown license type: '%s'", test.Type) diff --git a/components/licensor/ee/pkg/licensor/replicated.go b/components/licensor/ee/pkg/licensor/replicated.go index c39e0ecdb3513f..4793488174c9a2 100644 --- a/components/licensor/ee/pkg/licensor/replicated.go +++ b/components/licensor/ee/pkg/licensor/replicated.go @@ -92,7 +92,7 @@ func defaultReplicatedLicense() *Evaluator { } // newReplicatedEvaluator exists to allow mocking of client -func newReplicatedEvaluator(client *http.Client, domain string) (res *Evaluator) { +func newReplicatedEvaluator(client *http.Client) (res *Evaluator) { resp, err := client.Get(replicatedLicenseApiEndpoint) if err != nil { return &Evaluator{invalid: fmt.Sprintf("cannot query kots admin, %q", err)} @@ -121,10 +121,6 @@ func newReplicatedEvaluator(client *http.Client, domain string) (res *Evaluator) } } - if !matchesDomain(lic.Domain, domain) { - return defaultReplicatedLicense() - } - if replicatedPayload.ExpirationTime != nil { lic.ValidUntil = *replicatedPayload.ExpirationTime @@ -141,6 +137,6 @@ func newReplicatedEvaluator(client *http.Client, domain string) (res *Evaluator) } // NewReplicatedEvaluator gets the license data from the kots admin panel -func NewReplicatedEvaluator(domain string) (res *Evaluator) { - return newReplicatedEvaluator(&http.Client{Timeout: replicatedLicenseApiTimeout}, domain) +func NewReplicatedEvaluator() (res *Evaluator) { + return newReplicatedEvaluator(&http.Client{Timeout: replicatedLicenseApiTimeout}) } diff --git a/components/licensor/typescript/ee/main.go b/components/licensor/typescript/ee/main.go index cc000085d24b18..3cef8af627d5a0 100644 --- a/components/licensor/typescript/ee/main.go +++ b/components/licensor/typescript/ee/main.go @@ -25,7 +25,7 @@ func Init(key *C.char, domain *C.char) (id int) { id = nextID switch os.Getenv("GITPOD_LICENSE_TYPE") { case string(licensor.LicenseTypeReplicated): - instances[id] = licensor.NewReplicatedEvaluator(C.GoString(domain)) + instances[id] = licensor.NewReplicatedEvaluator() break default: instances[id] = licensor.NewGitpodEvaluator([]byte(C.GoString(key)), C.GoString(domain))