Movatterモバイル変換


[0]ホーム

URL:


license

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:12Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Overview

Package license provides the license parsing and validation logic for Coderd.Licensing in Coderd defines what features are allowed to be used in agiven deployment. Without a license, or with a license that grants 0 features,Coderd will refuse to execute some feature code paths. These features aretypically gated with a middleware that checks the license before allowingthe http request to proceed.

Terms:

  • FeatureName: A specific functionality that Coderd provides, such asexternal provisioners.

- Feature: Entitlement definition for a FeatureName. A feature can be:

  • "entitled": The feature is allowed to be used by the deployment.
  • "grace period": The feature is allowed to be used by the deployment,but the license is expired. There is a grace periodbefore the feature is disabled.
  • "not entitled": The deployment is not allowed to use the feature.Either by expiration, or by not being includedin the license.A feature can also be "disabled" that prevents usage of the featureeven if entitled. This is usually a deployment configuration option.
  • License: A signed JWT that lists the features that are allowed to be used bya given deployment. A license can have extra properties like,`IsTrial`, `DeploymentIDs`, etc that can be used to further defineusage of the license.
  • Entitlements: A parsed set of licenses. Yes you can have more than 1 licenseon a deployment! Entitlements will enumerate all features thatare allowed to be used.

Index

Constants

View Source
const (CurrentVersion        = 3HeaderKeyID           = "kid"AccountTypeSalesforce = "salesforce"VersionClaim          = "version")

Variables

View Source
var (ValidMethods = []string{"EdDSA"}ErrInvalidVersion        =xerrors.New("license must be version 3")ErrMissingKeyID          =xerrors.Errorf("JOSE header must contain %s",HeaderKeyID)ErrMissingLicenseExpires =xerrors.New("license missing license_expires")ErrMissingExp            =xerrors.New("exp claim missing or not parsable")ErrMultipleIssues        =xerrors.New("license has multiple issues; contact support"))

Functions

funcEntitlements

func Entitlements(ctxcontext.Context,dbdatabase.Store,replicaCountint,externalAuthCountint,keys map[string]ed25519.PublicKey,enablements map[codersdk.FeatureName]bool,) (codersdk.Entitlements,error)

Entitlements processes licenses to return whether features are enabled or not.

funcLicensesEntitlementsadded inv2.14.0

func LicensesEntitlements(nowtime.Time,licenses []database.License,enablements map[codersdk.FeatureName]bool,keys map[string]ed25519.PublicKey,featureArgumentsFeatureArguments,) (codersdk.Entitlements,error)

LicensesEntitlements returns the entitlements for licenses. Entitlements aremerged from all licenses and the highest entitlement is used for each feature.Arguments:

now: The time to use for checking license expiration.license: The license to check.enablements: Features can be explicitly disabled by the deployment even if             the license has the feature entitled. Features can also have             the 'feat.AlwaysEnable()' return true to disallow disabling.featureArguments: Additional arguments required by specific features.

funcParseRaw

func ParseRaw(lstring, keys map[string]ed25519.PublicKey) (jwt.MapClaims,error)

ParseRaw consumes a license and returns the claims.

Types

typeClaims

type Claims struct {jwt.RegisteredClaims// LicenseExpires is the end of the legit license term, and the start of the grace period, if// there is one.  The standard JWT claim "exp" (ExpiresAt in jwt.RegisteredClaims, above) is// the end of the grace period (identical to LicenseExpires if there is no grace period).// The reason we use the standard claim for the end of the grace period is that we want JWT// processing libraries to consider the token "valid" until then.LicenseExpires *jwt.NumericDate `json:"license_expires,omitempty"`AccountTypestring           `json:"account_type,omitempty"`AccountIDstring           `json:"account_id,omitempty"`// DeploymentIDs enforces the license can only be used on a set of deployments.DeploymentIDs []string            `json:"deployment_ids,omitempty"`Trialbool                `json:"trial"`FeatureSetcodersdk.FeatureSet `json:"feature_set"`// AllFeatures represents 'FeatureSet = FeatureSetEnterprise'// Deprecated: AllFeatures is deprecated in favor of FeatureSet.AllFeaturesbool     `json:"all_features,omitempty"`Versionuint64   `json:"version"`FeaturesFeatures `json:"features"`RequireTelemetrybool     `json:"require_telemetry,omitempty"`}

funcParseClaims

func ParseClaims(rawJWTstring, keys map[string]ed25519.PublicKey) (*Claims,error)

ParseClaims validates a raw JWT, and if valid, returns the claims. Ifunparsable or invalid, it returns an error

funcParseClaimsIgnoreNbfadded inv2.14.3

func ParseClaimsIgnoreNbf(rawJWTstring, keys map[string]ed25519.PublicKey) (*Claims,error)

ParseClaimsIgnoreNbf validates a raw JWT, but ignores `nbf` claim. If otherwise valid, it returnsthe claims. If unparsable or invalid, it returns an error. Ignoring the `nbf` (not before) isuseful to determine if a JWT _will_ become valid at any point now or in the future.

typeFeatureArgumentsadded inv2.14.0

type FeatureArguments struct {ActiveUserCountint64ReplicaCountintExternalAuthCountint}

typeFeatures

type Features map[codersdk.FeatureName]int64

typeMetricsCollectoradded inv2.3.1

type MetricsCollector struct {Entitlements *entitlements.Set}

func (*MetricsCollector)Collectadded inv2.3.1

func (mc *MetricsCollector) Collect(metricsCh chan<-prometheus.Metric)

func (*MetricsCollector)Describeadded inv2.3.1

func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp