hades

package module
v0.0.0-...-e64ec34 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2014 License: MIT Imports: 13 Imported by: 0

README

Hades

Build Status GoDoc

NOTE: UNDER DEVELOPMENT. NOT READY FOR USE.

Hades is a generic software licensing platform written in Go. It supports various licensing schemes to suit various needs.

The supported (or planned) licensing schemes are:

  • Product key: a key is generated and validated by the licensed software, no server is required. This does not prevent multiple installs or allows the licensed software to derive much information from the license key itself.
  • Product key with online activation: same as before but the key is activated online and the licensed software can download license restriction and ownership data from the server. Activation/validation can be used to prevent multiple-installs to a point.
  • Product key with online activation and authorization: as above, but the licensed software requires a timed authorization from the license server to run for a given period of time or until a specific point in time. Authorizations can be conditioned to a number of running instances.
  • Same as the above options, but with a license file instead of a bare key: the file contains all unmutable data associated with the license (restrictions, owner, expiration, etc.) and possibly SSL certificates (for interactions with the licensing server), and possibly miscellenous license-related files.

Secondary license schemes (can be combined with any of the above):

  • Quota-based license: A certain quota of a given resource (image files processed, Web pages served, MB stored, etc.) is associated with the license and directly monitored by the remote license server. This can be used to have multiple instances of the software running but limiting the total number of operations performed or similar. Quotas can be configured to reset after a certain period of time has elapsed, be based on a “live” counter that goes down when the instance making use of those resources releases them or dies, or be fixed (the license is issued for a one-off quota of X resources).
  • Machine-lock: Lock a license to a given machine by MAC address or network hostname. Requires an online-enabled license.

Hades consists of the following components:

  • Server: manages all licenses for one or more products, handles authorizations, activations, and validations as well as reporting, and license expiration/renewals.
  • Server CLI: allows administration of the server (pushing, revoking, renewing, fetching, and updating licenses).
  • Client libraries: these are linked against licensed software and the handle license validation and communication with the licensing server, if required.
  • License utility: generates license keys and files without a server using the same libraries the server would use. Licenses generated in this manner can then be sent to the license server, if so desired.

Documentation

Index

Constants

View Source
const ARMOR_MAGIC = "HADES-ARMOR"
View Source
const ARMOR_VERSION = 1
View Source
const VERSION_MAJOR = 0
View Source
const VERSION_MINOR = 1
View Source
const VERSION_PATCH = 0

Variables

View Source
var ArmorFooter = strings.Repeat("-", 25) + " END LICENSE " + strings.Repeat("-", 24)
View Source
var ArmorHeader = strings.Repeat("-", 25) + " BEGIN LICENSE " + strings.Repeat("-", 24)
View Source
var KEYPAIR_ECDSA = LicenseKeyPairType("ECDSA-2048")
View Source
var LICENSE_CLIENT = LicenseClass("CLIENT")
View Source
var LICENSE_ENDUSER = LicenseType("ENDUSER")
View Source
var LICENSE_MASTER = LicenseClass("MASTER")
View Source
var LICENSE_PRODUCER = LicenseType("PRODUCER")
View Source
var LICENSE_PRODUCT = LicenseType("PRODUCT")
View Source
var LICENSE_VERSION = LicenseType("VERSION")

Functions

func VersionNumber

func VersionNumber() string

Types

type ArmorEnvelope

type ArmorEnvelope struct {
	Magic     string
	Version   int
	Payload   []byte
	Signature []byte
}

type License

type License struct {
	ID          LicenseKey
	ParentID    LicenseKey
	Type        LicenseType
	Class       LicenseClass
	Created     time.Time
	Metadata    map[string]string
	KeyPairType LicenseKeyPairType
	PrivateKey  []byte
	PublicKey   []byte
}

func (*License) Armor

func (l *License) Armor() ([]byte, error)

type LicenseClass

type LicenseClass string

A license's class (master, client) essentially specifies what the license is to be used for, in broad terms. A master license is that of a software producer or program, and is used to sign other master licenses and client licenses and there can only be one master license for a given thing (software producer, program, program version, etc.). A client license, in turn has no key pair, can't be used for signing other licenses, and is the only license class a Hades-protected program can load.

type LicenseDatastore

type LicenseDatastore interface {
	SetupDatabase(url string) error
	GetLicense(LicenseKey) (*License, error)
	GetLicenseList() (*[]LicenseKey, error)
	GetLicenseListByParent(LicenseKey) (*License, error)
	StoreLicense(*License) error
	DeleteLicense(LicenseKey) error
}

LicenseDatastore is an interface designed to make the license database easily replaceable so the license server and the CLI application can use different database engines based on their different use cases. Plus, this way I get to change my mind about the datastore later on without having to make a lot of changes.

type LicenseKey

type LicenseKey []byte

Key format is as follows, in NAME(BYTES) format: CHECKSUM(4): truncated SHA-1 hash of parent keys (producer, product,

version) and the current key with the CHECKSUM field zeroed
out. Inclusion of the parent keys is mandatory if they exist.

EXTRA-1(2): available for custom use. EXTRA-2(2): available for custom use. EXTRA-3(2): available for custom use. RANDOM(6): this is the key proper, so to speak. It makes a given key unique. Please note that unused EXTRA fields can be used to increase the key space.

func LicenseKeyFromString

func LicenseKeyFromString(k string) (key LicenseKey, err error)

func NewLicenseKey

func NewLicenseKey(extra1, extra2, extra3 LicenseKeyExtra, parents ...LicenseKey) (LicenseKey, error)

func (LicenseKey) Bytes

func (k LicenseKey) Bytes() []byte

func (LicenseKey) IsValid

func (k LicenseKey) IsValid() bool

func (LicenseKey) String

func (k LicenseKey) String() string

type LicenseKeyExtra

type LicenseKeyExtra []byte

func (LicenseKeyExtra) IsValid

func (k LicenseKeyExtra) IsValid() bool

type LicenseKeyPairType

type LicenseKeyPairType string

Signing key pair type and bit-length.

type LicenseType

type LicenseType string

A license's type specifies what the licence is intended to represent (a producer, a product, etc.) All but LICENSE_CLIENT are master licenses.

type SQLite3Datastore

type SQLite3Datastore struct {
	// contains filtered or unexported fields
}

SQLite3Datastore implements LicenseDatastore for SQLite3-based storage.

func (*SQLite3Datastore) DeleteLicense

func (s *SQLite3Datastore) DeleteLicense(id LicenseKey) error

func (*SQLite3Datastore) GetLicense

func (s *SQLite3Datastore) GetLicense(id LicenseKey) (*License, error)

func (*SQLite3Datastore) GetLicenseList

func (s *SQLite3Datastore) GetLicenseList() (keys []LicenseKey, err error)

func (*SQLite3Datastore) GetLicenseListByParent

func (s *SQLite3Datastore) GetLicenseListByParent(parent LicenseKey) (keys []LicenseKey, err error)

func (*SQLite3Datastore) SetupDatabase

func (s *SQLite3Datastore) SetupDatabase(dbpath string) error

func (*SQLite3Datastore) StoreLicense

func (s *SQLite3Datastore) StoreLicense(license *License) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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