github.com/minio/console@v1.3.0/pkg/subnet/config.go (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2021 MinIO, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Affero General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 package subnet 18 19 import ( 20 "errors" 21 "log" 22 23 "github.com/minio/pkg/v2/licverifier" 24 ) 25 26 // GetLicenseInfoFromJWT will return license metadata from a jwt string license 27 func GetLicenseInfoFromJWT(license string, publicKeys []string) (*licverifier.LicenseInfo, error) { 28 if license == "" { 29 return nil, errors.New("license is not present") 30 } 31 for _, publicKey := range publicKeys { 32 lv, err := licverifier.NewLicenseVerifier([]byte(publicKey)) 33 if err != nil { 34 log.Print(err) 35 continue 36 } 37 licInfo, err := lv.Verify(license) 38 if err != nil { 39 log.Print(err) 40 continue 41 } 42 return &licInfo, nil 43 } 44 return nil, errors.New("invalid license key") 45 } 46 47 // MfaReq - JSON payload of the SUBNET mfa api 48 type MfaReq struct { 49 Username string `json:"username"` 50 OTP string `json:"otp"` 51 Token string `json:"token"` 52 } 53 54 type LoginResp struct { 55 AccessToken string 56 MfaToken string 57 }