mirror of
https://github.com/minio/minio.git
synced 2025-11-27 20:58:55 -05:00
Add ExpiresAt to LicenseInfo (#10293)
This commit is contained in:
committed by
GitHub
parent
0ebb73ee2e
commit
ccd967e3be
@@ -21,6 +21,7 @@ import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
)
|
||||
@@ -32,17 +33,19 @@ type LicenseVerifier struct {
|
||||
|
||||
// LicenseInfo holds customer metadata present in the license key.
|
||||
type LicenseInfo struct {
|
||||
Email string // Email of the license key requestor
|
||||
TeamName string // Subnet team name
|
||||
AccountID int64 // Subnet account id
|
||||
StorageCapacity int64 // Storage capacity used in TB
|
||||
ServiceType string // Subnet service type
|
||||
Email string // Email of the license key requestor
|
||||
TeamName string // Subnet team name
|
||||
AccountID int64 // Subnet account id
|
||||
StorageCapacity int64 // Storage capacity used in TB
|
||||
ServiceType string // Subnet service type
|
||||
ExpiresAt time.Time // Time of license expiry
|
||||
}
|
||||
|
||||
// license key JSON field names
|
||||
const (
|
||||
accountID = "accountId"
|
||||
sub = "sub"
|
||||
expiresAt = "exp"
|
||||
teamName = "teamName"
|
||||
capacity = "capacity"
|
||||
serviceType = "serviceType"
|
||||
@@ -71,6 +74,11 @@ func toLicenseInfo(claims jwt.MapClaims) (LicenseInfo, error) {
|
||||
if !ok {
|
||||
return LicenseInfo{}, errors.New("Invalid email in claims")
|
||||
}
|
||||
expiryTS, ok := claims[expiresAt].(float64)
|
||||
if !ok {
|
||||
return LicenseInfo{}, errors.New("Invalid time of expiry in claims")
|
||||
}
|
||||
expiresAt := time.Unix(int64(expiryTS), 0)
|
||||
tName, ok := claims[teamName].(string)
|
||||
if !ok {
|
||||
return LicenseInfo{}, errors.New("Invalid team name in claims")
|
||||
@@ -89,6 +97,7 @@ func toLicenseInfo(claims jwt.MapClaims) (LicenseInfo, error) {
|
||||
AccountID: int64(accID),
|
||||
StorageCapacity: int64(storageCap),
|
||||
ServiceType: sType,
|
||||
ExpiresAt: expiresAt,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user