Documentation
¶
Overview ¶
Package license provides Ed25519-signed license token creation, parsing, and verification.
Index ¶
- func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func MarshalPrivateKeyPEM(priv ed25519.PrivateKey) []byte
- func MarshalPublicKeyPEM(pub ed25519.PublicKey) []byte
- func UnmarshalPrivateKeyPEM(pemBytes []byte) (ed25519.PrivateKey, error)
- func UnmarshalPublicKeyPEM(pemBytes []byte) (ed25519.PublicKey, error)
- type LicenseToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
GenerateKeyPair generates a new Ed25519 key pair using crypto/rand.
func MarshalPrivateKeyPEM ¶
func MarshalPrivateKeyPEM(priv ed25519.PrivateKey) []byte
MarshalPrivateKeyPEM PEM-encodes an Ed25519 private key with type "ED25519 PRIVATE KEY".
func MarshalPublicKeyPEM ¶
MarshalPublicKeyPEM PEM-encodes an Ed25519 public key with type "ED25519 PUBLIC KEY".
func UnmarshalPrivateKeyPEM ¶
func UnmarshalPrivateKeyPEM(pemBytes []byte) (ed25519.PrivateKey, error)
UnmarshalPrivateKeyPEM decodes a PEM-encoded Ed25519 private key.
Types ¶
type LicenseToken ¶
type LicenseToken struct {
LicenseID string `json:"lid"`
TenantID string `json:"tid"`
Organization string `json:"org"`
Tier string `json:"tier"`
Features []string `json:"feat"`
MaxWorkflows int `json:"max_wf"`
MaxPlugins int `json:"max_pl"`
IssuedAt int64 `json:"iat"`
ExpiresAt int64 `json:"exp"`
// contains filtered or unexported fields
}
LicenseToken holds the claims embedded in a signed license token.
func Parse ¶
func Parse(tokenStr string) (*LicenseToken, error)
Parse splits tokenStr on dots, decodes the base64url payload, and returns the token. It does NOT verify the signature.
func (*LicenseToken) HasFeature ¶
func (t *LicenseToken) HasFeature(name string) bool
HasFeature returns true if the given feature name is present in the Features slice.
func (*LicenseToken) IsExpired ¶
func (t *LicenseToken) IsExpired() bool
IsExpired returns true if ExpiresAt is in the past.
func (*LicenseToken) Sign ¶
func (t *LicenseToken) Sign(privateKey ed25519.PrivateKey) (string, error)
Sign produces a signed license token string in the format: wflic.v1.<base64url-payload>.<base64url-signature>