licensing

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeaderKeyID     = "X-Graymeta-Key-Id"
	HTTPHeaderSignature = "X-Graymeta-Signature"
)

Canonical HTTP header names for the HMAC key ID and signature headers

Variables

View Source
var ErrLicenseInvalidSignature = errors.New("license contains invalid signature")

ErrLicenseInvalidSignature is the error returned when the license has an invalid signature

Functions

func IsExpired

func IsExpired(l License) bool

IsExpired returns true if the license is expired

func LicenseFromKey

func LicenseFromKey(licenseKey, publicKey string, dest interface{}) error

LicenseFromKey takes a licenseKey and a public key and rehydrates it into a the destination.

func Sign

func Sign(privateKey string, l interface{}) (string, error)

Sign signs a license and returns the base32 encoded license key

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is an abstraction around a http client.

type EnvelopePingResponse

type EnvelopePingResponse struct {
	Payload string `json:"payload"`
}

EnvelopePingResponse wraps the signed ping response from the server

type License

type License interface {
	ExpiresAt() time.Time
}

License is the minimum requirements a struct has to expose for being able to be a product license

type LicenseMF2

type LicenseMF2 struct {
	// Expiration is the timestamp at which the license expires
	Expiration time.Time `json:"expiration"`
	// BaseURL is the platform's base URL. We include this in the signed license to
	// prevent customers from spinning up multiple instances of the platform behind
	// a load balancer
	BaseURL string `json:"base_url"`
	// EnforceBaseURLCheck dictates whether or not we should enforce the BaseURL
	// check. This is necessary because we want to use a single license across all
	// sites hosted by GrayMeta (in which case this would be false). For our typical
	// Enterprise Terraform based customers, this will be true
	EnforceBaseURLCheck bool `json:"enforce_base_url_check"`
	// LicenseGeneratedAt is the timestamp when the license was generated
	LicenseGeneratedAt time.Time `json:"license_generated_at"`
	// LicenseGenerationHost is the hostname of the server where the license was generated
	LicenseGenerationHost string `json:"license_generation_host"`
	// LicenseHost is the host for the licensing server
	LicenseHost string `json:"license_host,omitempty"`
	// UsageHost is the url for the usage server
	UsageHost string `json:"usage_host,omitempty"`
	// PublicKey is the public key used to secure communications with the GrayMeta
	// LicenseHost and UsageHost
	PublicKey string `json:"public_key,omitempty"`
	// PrivateKey is the private key used to secure communications with the GrayMeta
	// LicenseHost and UsageHost
	PrivateKey string `json:"private_key,omitempty"`
	// RemoteUsageEnabled is the flag to turn on/off remote usage reporting
	RemoteUsageEnabled bool `json:"remote_usage_enabled"`
	// LicenseChecksEnabled is the flag to turn on/off remote kill/licensing checks
	LicenseChecksEnabled bool `json:"license_checks_enabled"`
}

LicenseMF2 is a GrayMeta/Curio Platform License

func (LicenseMF2) ExpiresAt

func (l LicenseMF2) ExpiresAt() time.Time

ExpiresAt returns the license expiration time

func (LicenseMF2) Pinger

func (l LicenseMF2) Pinger(client Doer, licensePublicKey string) *PingerMF2

Pinger gets a new Pinger for this license. The licensePublicKey is the public key used to sign the mf2 licenses themselves.

type PingRequestMF2

type PingRequestMF2 struct {
	CurrentTime time.Time `json:"current_time"`
}

PingRequestMF2 is the request body for a license ping

type PingResponseMF2

type PingResponseMF2 struct {
	Enabled bool `json:"enabled"`
}

PingResponseMF2 is the response body from the license server

type PingerMF2

type PingerMF2 struct {
	// contains filtered or unexported fields
}

PingerMF2 executes ping requests to the MF2 license server

func (PingerMF2) Ping

func (p PingerMF2) Ping() (PingResponseMF2, error)

Ping initiates a ping request to the remote license server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳