Add endpoint to get api key from subnet (#2175)

This commit is contained in:
Javier Adriel
2022-07-18 17:51:07 -05:00
committed by GitHub
parent aea749d82f
commit 78d4d4c89e
12 changed files with 749 additions and 0 deletions

View File

@@ -165,3 +165,13 @@ func ParseLicense(client http.ClientI, license string) (*licverifier.LicenseInfo
return licenseInfo, nil
}
func GetAPIKey(client http.ClientI, token string) (string, error) {
resp, err := subnetGetReq(client, subnetAPIKeyURL(), subnetAuthHeaders(token))
if err != nil {
return "", err
}
respJSON := gjson.Parse(resp)
apiKey := respJSON.Get("api_key").String()
return apiKey, nil
}

View File

@@ -56,6 +56,10 @@ func subnetMFAURL() string {
return subnetBaseURL() + "/api/auth/mfa-login"
}
func subnetAPIKeyURL() string {
return subnetBaseURL() + "/api/auth/api-key"
}
func GenerateRegToken(clusterRegInfo mc.ClusterRegistrationInfo) (string, error) {
token, e := json.Marshal(clusterRegInfo)
if e != nil {