Documentation
¶
Overview ¶
Package license implements offline validation of signed 2papi licenses.
Format (one line): <prefix>:<base64url(payloadJSON)>.<base64url(sig)>
- prefix is the edition id ("ent" | "cloud");
- sig = ed25519.Sign(private, []byte(prefix+"."+b64payload)) — the prefix is inside the signature, so swapping editions breaks it;
- payload is canonical JSON (see License struct).
Public key resolution: env 2PAPI_LICENSE_PUBKEY (hex) overrides the embedded default. No key configured => every license fails with ErrNoKey and the caller degrades to OSS. Validation never touches the network — air-gapped deployments work out of the box.
Spec: plan/build-spine-specs.md (шаг 1 хребта).
Index ¶
Constants ¶
const ( // PubKeyEnv overrides the embedded public key (hex-encoded). PubKeyEnv = "2PAPI_LICENSE_PUBKEY" // DefaultPubKeyHex is replaced at release time with the real // production key. Empty means "no licenses trusted yet". DefaultPubKeyHex = "" // Edition ids allowed as license prefix/payload edition. EdEnt = "ent" EdCloud = "cloud" )
Variables ¶
var ( ErrBadFormat = errors.New("license: bad format") ErrBadSig = errors.New("license: bad signature") ErrExpired = errors.New("license: expired") ErrNotYet = errors.New("license: not valid yet") ErrNoKey = errors.New("license: no trusted public key configured") ErrUnknownFeature = errors.New("license: unknown feature") ErrEditionMismatch = errors.New("license: edition mismatch") )
Functions ¶
This section is empty.
Types ¶
type License ¶
type License struct {
Edition string `json:"ed"`
CustomerID string `json:"cid"`
CapacityM int64 `json:"cap"` // годовая ёмкость запросов, млн; 0 = без лимита
IssuedAt int64 `json:"iat"` // unix sec
ExpiresAt int64 `json:"exp"` // unix sec
Features []string `json:"f,omitempty"` // включённые фичи
NotBefore int64 `json:"nbf,omitempty"` // unix sec
Trial bool `json:"trial,omitempty"`
}
License is the decoded payload. JSON field order here is also the canonical generation order (lexicographic) for our own keygen.