Skip to content

[licensor] allow invalid domain in professional license #10069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions components/licensor/ee/pkg/licensor/licensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/licensor/ee/pkg/licensor/licensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions components/licensor/ee/pkg/licensor/replicated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down Expand Up @@ -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

Expand All @@ -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})
}
2 changes: 1 addition & 1 deletion components/licensor/typescript/ee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down