entitlement

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VendorKey is the key in the entitlement secret
	// that holds the vendor name.
	VendorKey = "vendor"

	// TokenKey is the key in the entitlement secret
	// that holds the token.
	TokenKey = "token"

	// DefaultVendor is the default vendor name.
	DefaultVendor = "controlplane"

	// MarketplaceTypeEnvKey is the environment variable key
	// that holds the marketplace type.
	MarketplaceTypeEnvKey = "MARKETPLACE_TYPE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonClient

type AmazonClient struct {
	Vendor string
	// contains filtered or unexported fields
}

AmazonClient is an entitlement client for the ControlPlane Enterprise for Flux CD AWS Marketplace product. https://aws.amazon.com/marketplace/pp/prodview-ndm54wno7tayg

func NewAmazonClient

func NewAmazonClient(vendor string) (*AmazonClient, error)

NewAmazonClient creates a new AmazonClient using the default AWS configuration and the current region.

func (*AmazonClient) GetVendor

func (c *AmazonClient) GetVendor() string

GetVendor returns the vendor name.

func (*AmazonClient) RegisterUsage

func (c *AmazonClient) RegisterUsage(ctx context.Context, id string) (string, error)

RegisterUsage registers the usage with AWS Marketplace metering service and returns a JWT token.

func (*AmazonClient) Verify

func (c *AmazonClient) Verify(token, id string) (bool, error)

Verify verifies the JWT token is signed with the AWS Marketplace public key and checks the product code, nonce and public key version claims.

type Client

type Client interface {
	// RegisterUsage registers the usage with the entitlement service
	// and returns a signed JWT token.
	RegisterUsage(ctx context.Context, id string) (string, error)

	// Verify verifies that the token is signed by the
	// entitlement service and matches the usage id.
	Verify(token, id string) (bool, error)

	// GetVendor returns the vendor name.
	GetVendor() string
}

Client is the interface for entitlement clients that can register usage and verify tokens.

func NewClient

func NewClient() (Client, error)

NewClient returns a new entitlement client based on the marketplace type environment variable.

type DefaultClient

type DefaultClient struct {
	Vendor string
}

DefaultClient is an offline entitlement client. This client uses a SHA256 digest to generate and verify tokens.

func (*DefaultClient) GetVendor

func (c *DefaultClient) GetVendor() string

GetVendor returns the vendor name.

func (*DefaultClient) RegisterUsage

func (c *DefaultClient) RegisterUsage(ctx context.Context, id string) (string, error)

RegisterUsage registers the usage with the default entitlement client.

func (*DefaultClient) Verify

func (c *DefaultClient) Verify(token, id string) (bool, error)

Verify verifies the token matches the SHA256 digest of the vendor id.

Jump to

Keyboard shortcuts

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