Documentation ¶
Overview ¶
Package licverifier implements a simple library to verify MinIO Subnet license keys.
Example ¶
Example creates a LicenseVerifier using the ECDSA public key in pemBytes. It uses the Verify method of the LicenseVerifier to verify and extract the claims present in the license key.
pemBytes := []byte(`-----BEGIN PUBLIC KEY----- MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEbo+e1wpBY4tBq9AONKww3Kq7m6QP/TBQ mr/cKCUyBL7rcAvg0zNq1vcSrUSGlAmY3SEDCu3GOKnjG/U4E7+p957ocWSV+mQU 9NKlTdQFGF3+aO6jbQ4hX/S5qPyF+a3z -----END PUBLIC KEY-----`) lv, err := NewLicenseVerifier(pemBytes) if err != nil { fmt.Println("Failed to create license verifier", err) } licenseKey := "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJrcCtjMUBtaW5pby5pbyIsInRlYW1OYW1lIjoiR3JpbmdvdHRzIEluYy4iLCJleHAiOjEuNjI4MjAxODYyNjgwNzM3Nzc1ZTksImNhcGFjaXR5Ijo1MCwiaWF0IjoxLjU5NjY2NTg2MjY4MDczNzc3NWU5LCJhY2NvdW50SWQiOjEsInNlcnZpY2VUeXBlIjoiU1RBTkRBUkQifQ._2EgZpjVGo3hRacO2MNavDqZoaP-hwDQ745Z-t-N6lKDwhHOzwhENb9UhiubOQ_yTJ9Ia5EqMhQrC1QCrk8-ThiftmjFGKTyYw5j7gvox_5L-R8HIegACynVlmBlF6IV" licInfo, err := lv.Verify(licenseKey) if err != nil { fmt.Println("Failed to verify license key", err) } fmt.Println("License metadata", licInfo)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LicenseInfo ¶
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 ExpiresAt time.Time // Time of license expiry }
LicenseInfo holds customer metadata present in the license key.
type LicenseVerifier ¶
type LicenseVerifier struct {
// contains filtered or unexported fields
}
LicenseVerifier needs an ECDSA public key in PEM format for initialization.
func NewLicenseVerifier ¶
func NewLicenseVerifier(pemBytes []byte) (*LicenseVerifier, error)
NewLicenseVerifier returns an initialized license verifier with the given ECDSA public key in PEM format.
func (*LicenseVerifier) Verify ¶
func (lv *LicenseVerifier) Verify(license string) (LicenseInfo, error)
Verify verifies the license key and validates the claims present in it.
Click to show internal directories.
Click to hide internal directories.