licensing

package
v0.146.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FeatureCentralWatchCoordinator = "central_watch_coordinator"
	FeatureSharedExecutionStore    = "shared_execution_store"
	FeatureTeamAuditTrail          = "team_audit_trail"
	FeatureSMSNotifications        = "sms_notifications"
)

Supported Commercial Feature Names

View Source
const (
	TierPro                  = "pro"
	TierEnterpriseSelfHosted = "enterprise_self_hosted"
)

Supported Commercial Tiers

View Source
const GracePeriodDuration = 14 * 24 * time.Hour

Standard Grace Period: 14 days after license expiration

Variables

View Source
var (
	ErrLicenseMissing     = errors.New("commercial license key is required")
	ErrInvalidLicense     = errors.New("invalid commercial license format")
	ErrInvalidSignature   = errors.New("invalid commercial license signature")
	ErrLicenseExpired     = errors.New("commercial license has expired and exceeded the grace period")
	ErrFeatureNotEntitled = errors.New("feature not entitled under current commercial license")
	ErrCapacityExceeded   = errors.New("license capacity exceeded")
	ErrInvalidTier        = errors.New("unrecognized license tier")
)

Functions

func CheckFeature

func CheckFeature(feature string) error

CheckFeature checks the currently active license for the specified feature.

func SetActiveLicense

func SetActiveLicense(l *License)

SetActiveLicense installs a verified license into process memory.

func SetPublicKey

func SetPublicKey(pub ed25519.PublicKey) func()

SetPublicKey configures the Ed25519 public key used for offline verification. Returns a restore function suitable for defer in unit tests.

func SetStderrWriter

func SetStderrWriter(w io.Writer) func()

SetStderrWriter sets the diagnostic writer for grace-period alerts.

func SetTimeNow

func SetTimeNow(fn func() time.Time) func()

SetTimeNow overrides time.Now for deterministic testing.

func SignLicense

func SignLicense(claims Claims, privKey ed25519.PrivateKey) (string, error)

SignLicense creates a signed license key from claims and an Ed25519 private key. Primarily used by tests and the license generation utility.

Types

type Capacity

type Capacity struct {
	MaxCoordinators int `json:"max_coordinators,omitempty"`
	MaxRunners      int `json:"max_runners,omitempty"`
	MaxUsers        int `json:"max_users,omitempty"`
}

Capacity specifies resource limits authorized by a license.

type Claims

type Claims struct {
	ID           string    `json:"id"`
	Organization string    `json:"organization"`
	IssuedAt     time.Time `json:"issued_at"`
	ExpiresAt    time.Time `json:"expires_at"`
	Tier         string    `json:"tier"`
	Capacity     Capacity  `json:"capacity"`
	Features     []string  `json:"features"`
}

Claims represents the cryptographically signed license payload.

type CoordinatorEntitlementChecker

type CoordinatorEntitlementChecker struct {
	LicenseKey string
}

CoordinatorEntitlementChecker validates commercial licensing for the centralized watch coordinator.

func NewCoordinatorEntitlementChecker

func NewCoordinatorEntitlementChecker(licenseKey string) *CoordinatorEntitlementChecker

NewCoordinatorEntitlementChecker creates a new entitlement checker for watch coordinator deployments.

func (*CoordinatorEntitlementChecker) CheckEntitlement

func (c *CoordinatorEntitlementChecker) CheckEntitlement() error

CheckEntitlement verifies that the coordinator is entitled under an active commercial license. In evaluation/unlicensed standalone mode, it logs an advisory message to stderr.

type License

type License struct {
	Claims      Claims `json:"claims"`
	InGrace     bool   `json:"in_grace"`
	DaysInGrace int    `json:"days_in_grace,omitempty"`
}

License represents a verified and decoded commercial license.

func GetActiveLicense

func GetActiveLicense() *License

GetActiveLicense retrieves the currently installed commercial license.

func LoadLicenseFromEnv

func LoadLicenseFromEnv() (*License, error)

LoadLicenseFromEnv reads a license key from DATATUG_LICENSE_KEY or DATATUG_LICENSE_FILE, verifies it, and registers it as the active license.

func VerifyLicense

func VerifyLicense(licenseKey string) (*License, error)

VerifyLicense decodes, cryptographically checks the Ed25519 signature, and validates the claims and expiration with a 14-day grace period.

The licenseKey may be formatted as:

  • "<base64_claims>.<base64_signature>"
  • or base64-encoded JSON {"payload": "<base64_claims>", "signature": "<base64_signature>"}

Verification is completely offline and air-gapped without network calls.

func (*License) CheckCoordinatorCapacity

func (l *License) CheckCoordinatorCapacity(coordinatorCount int) error

CheckCoordinatorCapacity checks if coordinatorCount is within licensed capacity.

func (*License) CheckFeature

func (l *License) CheckFeature(feature string) error

CheckFeature verifies that the receiver license entitles the given feature.

func (*License) CheckRunnerCapacity

func (l *License) CheckRunnerCapacity(runnerCount int) error

CheckRunnerCapacity checks if runnerCount is within licensed capacity.

func (*License) CheckUserCapacity

func (l *License) CheckUserCapacity(userCount int) error

CheckUserCapacity checks if userCount is within licensed capacity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL