configure public key and related license variables at build time (#22202)

Instead of being completely hardcoded, public key is now set at build time according to build tag (test key if `testlicensekey` tag is passed to go build, production key otherwise). A `isProdLicensePublicKey` is also available for determining if the prod license key is being used. It is needed for choosing whether to point to production or test environment CWS.

The test license key and CWS url values in this value are set to production values in this PR, but will be updated to the test values once we are ready to do the necessary updates to test environment spinwicks.
Этот коммит содержится в:
Nathaniel Allred
2023-03-08 09:14:14 -06:00
коммит произвёл GitHub
родитель 346fab1620
Коммит de63ddfd9b
13 изменённых файлов: 113 добавлений и 54 удалений

Просмотреть файл

@@ -16,13 +16,9 @@ import (
)
const (
LicenseEnv = "MM_LICENSE"
LicenseRenewalURL = "https://customers.mattermost.com/subscribe/renew"
JWTDefaultTokenExpiration = 7 * 24 * time.Hour // 7 days of expiration
)
var RequestTrialURL = "https://customers.mattermost.com/api/v1/trials"
// ensure the license service wrapper implements `product.LicenseService`
var _ product.LicenseService = (*licenseWrapper)(nil)

Просмотреть файл

@@ -23,14 +23,9 @@ import (
const (
LicenseEnv = "MM_LICENSE"
LicenseRenewalURL = "https://customers.mattermost.com/subscribe/renew"
JWTDefaultTokenExpiration = 7 * 24 * time.Hour // 7 days of expiration
)
var (
RequestTrialURL = "https://customers.mattermost.com/api/v1/trials"
)
// JWTClaims custom JWT claims with the needed information for the
// renewal process
type JWTClaims struct {
@@ -302,7 +297,7 @@ func (ps *PlatformService) RequestTrialLicense(trialRequest *model.TrialLicenseR
return model.NewAppError("RequestTrialLicense", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
resp, err := http.Post(RequestTrialURL, "application/json", bytes.NewBuffer(trialRequestJSON))
resp, err := http.Post(ps.getRequestTrialURL(), "application/json", bytes.NewBuffer(trialRequestJSON))
if err != nil {
return model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.app_error", nil, "", http.StatusBadRequest).Wrap(err)
}
@@ -379,6 +374,13 @@ func (ps *PlatformService) GenerateLicenseRenewalLink() (string, string, *model.
if err != nil {
return "", "", err
}
renewalLink := LicenseRenewalURL + "?token=" + renewalToken
return renewalLink, renewalToken, nil
return fmt.Sprintf("%s?token=%s", ps.getLicenseRenewalURL(), renewalToken), renewalToken, nil
}
func (ps *PlatformService) getLicenseRenewalURL() string {
return fmt.Sprintf("%s/subscribe/renew", *ps.Config().CloudSettings.CWSURL)
}
func (ps *PlatformService) getRequestTrialURL() string {
return fmt.Sprintf("%s/api/v1/trials", *ps.Config().CloudSettings.CWSURL)
}