Validate license against deployment id (#4161)
The command `mc license update` should error out in case the deployment id from the license doesn't match the cluster.
This commit is contained in:
+13
-8
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
@@ -172,13 +173,6 @@ func mainLicenseRegister(ctx *cli.Context) error {
|
||||
fatalIf(probe.NewError(e), "unable to parse input values")
|
||||
}
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client := getClient(aliasedURL)
|
||||
|
||||
// Fetch info of all servers (cluster or single server)
|
||||
admInfo, e := client.ServerInfo(globalContext)
|
||||
fatalIf(probe.NewError(e), "Unable to fetch cluster info")
|
||||
|
||||
alias, _ := url2Alias(aliasedURL)
|
||||
clusterName := ctx.String("name")
|
||||
if len(clusterName) == 0 {
|
||||
@@ -189,7 +183,7 @@ func mainLicenseRegister(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
regInfo := getClusterRegInfo(admInfo, clusterName)
|
||||
regInfo := getClusterRegInfo(getAdminInfo(aliasedURL), clusterName)
|
||||
|
||||
alreadyRegistered := false
|
||||
apiKey, lic, e := getSubnetCreds(alias)
|
||||
@@ -234,3 +228,14 @@ func registerOnline(clusterRegInfo ClusterRegistrationInfo, alias string, accAPI
|
||||
|
||||
extractAndSaveSubnetCreds(alias, resp)
|
||||
}
|
||||
|
||||
func getAdminInfo(aliasedURL string) madmin.InfoMessage {
|
||||
// Create a new MinIO Admin Client
|
||||
client := getClient(aliasedURL)
|
||||
|
||||
// Fetch info of all servers (cluster or single server)
|
||||
admInfo, e := client.ServerInfo(globalContext)
|
||||
fatalIf(probe.NewError(e), "Unable to fetch cluster info")
|
||||
|
||||
return admInfo
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ func performLicenseUpdate(licFile string, alias string, airgap bool) licUpdateMe
|
||||
fatalIf(errDummy().Trace(), fmt.Sprintf("License has expired on %s", li.ExpiresAt))
|
||||
}
|
||||
|
||||
if li.DeploymentID != getAdminInfo(alias).DeploymentID {
|
||||
fatalIf(errDummy().Trace(), fmt.Sprintf("License is invalid for the deployment %s", alias))
|
||||
}
|
||||
|
||||
setSubnetCreds(alias, "", lic)
|
||||
return lum
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user