Documentation
¶
Index ¶
- Constants
- Variables
- func CheckFeature(feature string) error
- func SetActiveLicense(l *License)
- func SetPublicKey(pub ed25519.PublicKey) func()
- func SetStderrWriter(w io.Writer) func()
- func SetTimeNow(fn func() time.Time) func()
- func SignLicense(claims Claims, privKey ed25519.PrivateKey) (string, error)
- type Capacity
- type Claims
- type CoordinatorEntitlementChecker
- type License
Constants ¶
const ( FeatureCentralWatchCoordinator = "central_watch_coordinator" FeatureTeamAuditTrail = "team_audit_trail" FeatureSMSNotifications = "sms_notifications" )
Supported Commercial Feature Names
const ( TierPro = "pro" TierEnterpriseSelfHosted = "enterprise_self_hosted" )
Supported Commercial Tiers
const GracePeriodDuration = 14 * 24 * time.Hour
Standard Grace Period: 14 days after license expiration
Variables ¶
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 ¶
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 ¶
SetPublicKey configures the Ed25519 public key used for offline verification. Returns a restore function suitable for defer in unit tests.
func SetStderrWriter ¶
SetStderrWriter sets the diagnostic writer for grace-period alerts.
func SetTimeNow ¶
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 ¶
LoadLicenseFromEnv reads a license key from DATATUG_LICENSE_KEY or DATATUG_LICENSE_FILE, verifies it, and registers it as the active license.
func VerifyLicense ¶
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 ¶
CheckCoordinatorCapacity checks if coordinatorCount is within licensed capacity.
func (*License) CheckFeature ¶
CheckFeature verifies that the receiver license entitles the given feature.
func (*License) CheckRunnerCapacity ¶
CheckRunnerCapacity checks if runnerCount is within licensed capacity.
func (*License) CheckUserCapacity ¶
CheckUserCapacity checks if userCount is within licensed capacity.