read license from envt variable (#2259)
This commit is contained in:
committed by
GitHub
parent
d279f722f8
commit
9821beb1de
@@ -25,12 +25,7 @@ import { containerForHeader } from "../Common/FormComponents/common/styleLibrary
|
||||
import PageHeader from "../Common/PageHeader/PageHeader";
|
||||
import api from "../../../common/api";
|
||||
import { ArrowRightLink, HelpIconFilled, LoginMinIOLogo } from "../../../icons";
|
||||
import { hasPermission } from "../../../common/SecureComponent";
|
||||
import {
|
||||
CONSOLE_UI_RESOURCE,
|
||||
IAM_PAGES,
|
||||
IAM_PAGES_PERMISSIONS,
|
||||
} from "../../../common/SecureComponent/permissions";
|
||||
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
|
||||
import LicensePlans from "./LicensePlans";
|
||||
import { Link } from "react-router-dom";
|
||||
import PageLayout from "../Common/Layout/PageLayout";
|
||||
@@ -131,12 +126,6 @@ const License = () => {
|
||||
const [isLicenseConsentOpen, setIsLicenseConsentOpen] =
|
||||
useState<boolean>(false);
|
||||
|
||||
const getSubnetInfo = hasPermission(
|
||||
CONSOLE_UI_RESOURCE,
|
||||
IAM_PAGES_PERMISSIONS[IAM_PAGES.LICENSE],
|
||||
true
|
||||
);
|
||||
|
||||
const closeModalAndFetchLicenseInfo = () => {
|
||||
setActivateProductModal(false);
|
||||
fetchLicenseInfo();
|
||||
@@ -164,32 +153,28 @@ const License = () => {
|
||||
if (loadingLicenseInfo) {
|
||||
return;
|
||||
}
|
||||
if (getSubnetInfo) {
|
||||
setLoadingLicenseInfo(true);
|
||||
api
|
||||
.invoke("GET", `/api/v1/subnet/info`)
|
||||
.then((res: SubnetInfo) => {
|
||||
if (res) {
|
||||
if (res.plan === "STANDARD") {
|
||||
setCurrentPlanID(1);
|
||||
} else if (res.plan === "ENTERPRISE") {
|
||||
setCurrentPlanID(2);
|
||||
} else {
|
||||
setCurrentPlanID(1);
|
||||
}
|
||||
setLicenseInfo(res);
|
||||
setLoadingLicenseInfo(true);
|
||||
api
|
||||
.invoke("GET", `/api/v1/subnet/info`)
|
||||
.then((res: SubnetInfo) => {
|
||||
if (res) {
|
||||
if (res.plan === "STANDARD") {
|
||||
setCurrentPlanID(1);
|
||||
} else if (res.plan === "ENTERPRISE") {
|
||||
setCurrentPlanID(2);
|
||||
} else {
|
||||
setCurrentPlanID(1);
|
||||
}
|
||||
setClusterRegistered(true);
|
||||
setLoadingLicenseInfo(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setClusterRegistered(false);
|
||||
setLoadingLicenseInfo(false);
|
||||
});
|
||||
} else {
|
||||
setLoadingLicenseInfo(false);
|
||||
}
|
||||
}, [loadingLicenseInfo, getSubnetInfo]);
|
||||
setLicenseInfo(res);
|
||||
}
|
||||
setClusterRegistered(true);
|
||||
setLoadingLicenseInfo(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setClusterRegistered(false);
|
||||
setLoadingLicenseInfo(false);
|
||||
});
|
||||
}, [loadingLicenseInfo]);
|
||||
|
||||
useEffect(() => {
|
||||
if (initialLicenseLoading) {
|
||||
|
||||
@@ -190,7 +190,10 @@ const Register = ({ classes }: IRegister) => {
|
||||
setLoadingLicenseInfo(false);
|
||||
})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
if (err.errorMessage !== "License not found") {
|
||||
if (
|
||||
err.detailedError.toLowerCase() !==
|
||||
"License is not present".toLowerCase()
|
||||
) {
|
||||
dispatch(setErrorSnackMessage(err));
|
||||
}
|
||||
setClusterRegistered(false);
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
xhttp "github.com/minio/console/pkg/http"
|
||||
|
||||
@@ -307,22 +308,11 @@ func GetSubnetRegisterResponse(session *models.Principal, params subnetApi.Subne
|
||||
func GetSubnetInfoResponse(session *models.Principal, params subnetApi.SubnetInfoParams) (*models.License, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
subnetTokens, err := GetSubnetKeyFromMinIOConfig(ctx, adminClient)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
if subnetTokens.APIKey == "" {
|
||||
return nil, ErrorWithContext(ctx, ErrLicenseNotFound)
|
||||
}
|
||||
client := &xhttp.Client{
|
||||
Client: GetConsoleHTTPClient(),
|
||||
}
|
||||
licenseInfo, err := subnet.ParseLicense(client, subnetTokens.License)
|
||||
|
||||
licenseInfo, err := subnet.ParseLicense(client, os.Getenv("CONSOLE_SUBNET_LICENSE"))
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user