Implement offline license verification (T-502)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package licensing
|
||||
|
||||
import "time"
|
||||
|
||||
// License is a verified License v1 document. It never contains the source
|
||||
// document, signature, public key, or raw machine identifiers.
|
||||
type License struct {
|
||||
LicenseID string
|
||||
MachineHash string
|
||||
Products []string
|
||||
IssuedAt time.Time
|
||||
Perpetual bool
|
||||
UpdatePolicy string
|
||||
RebindPolicy string
|
||||
}
|
||||
|
||||
// AuthorizesProduct reports whether this verified license lists productID.
|
||||
func (license License) AuthorizesProduct(productID string) bool {
|
||||
for _, licensedProduct := range license.Products {
|
||||
if licensedProduct == productID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user