licence

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoLicence     = errors.New("no licence key provided")
	ErrExpired       = errors.New("licence key has expired")
	ErrInvalidIssuer = errors.New("licence key issuer is invalid")
	ErrMalformed     = errors.New("licence key is malformed")
)

Functions

func HasFeature

func HasFeature(feature string) bool

HasFeature returns true if the active licence includes the named feature.

func Init

func Init(token string, activeUsers int)

Init loads the licence key from the environment, validates it, logs the result, and stores it in global state. activeUsers is the current DB user count for seat check. Call once at startup after the DB is ready.

func IsProEnabled

func IsProEnabled() bool

IsProEnabled returns true if a valid, non-expired Pro licence is active.

func SetForTest

func SetForTest(token string)

SetForTest replaces the global licence state for unit tests. Pass an empty string to reset to OSS mode.

func SetPublicKeyForTest

func SetPublicKeyForTest(pemBytes []byte)

SetPublicKeyForTest overrides the embedded production public key for unit tests. Pass nil to restore the production key.

Types

type Licence

type Licence struct {
	CustomerID string
	OrgName    string
	Seats      int
	Features   []string
}

Licence holds the decoded, verified claims from a Pro licence key.

func Load

func Load(token string) (*Licence, error)

Load parses and cryptographically verifies a licence key string. Returns ErrNoLicence for empty input, ErrExpired for expired keys, ErrInvalidIssuer for wrong issuer, ErrMalformed for missing required claims. Any other error indicates a forged or corrupted token.

func (*Licence) SeatLimitExceeded

func (l *Licence) SeatLimitExceeded(activeUsers int) bool

SeatLimitExceeded returns true when activeUsers is within the seat limit. Returns false when the limit is exceeded (caller should warn, not crash).

Jump to

Keyboard shortcuts

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