modules

package
v11.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

package modules allows external packages override certain behavioral aspects of teleport

Index

Constants

View Source
const (
	// BuildOSS specifies open source build type
	BuildOSS = "oss"
	// BuildEnterprise specifies enterprise build type
	BuildEnterprise = "ent"
)

Variables

This section is empty.

Functions

func SetModules

func SetModules(m Modules)

SetModules sets the modules interface

func SetTestModules

func SetTestModules(t *testing.T, testModules *TestModules)

SetTestModules sets the value returned from GetModules to testModules and reverts the change in the test cleanup function. It must not be used in parallel tests.

func TestWithFakeModules(t *testing.T) {
   modules.SetTestModules(t, &modules.TestModules{
     TestBuildType: modules.BuildEnterprise,
     TestFeatures: modules.Features{
        Cloud: true,
     },
   })

   // test implementation

   // cleanup will revert module changes after test completes
}

func ValidateResource

func ValidateResource(res types.Resource) error

ValidateResource performs additional resource checks.

Types

type Features

type Features struct {
	// Kubernetes enables Kubernetes Access product
	Kubernetes bool
	// App enables Application Access product
	App bool
	// DB enables database access product
	DB bool
	// OIDC enables OIDC connectors
	OIDC bool
	// SAML enables SAML connectors
	SAML bool
	// AccessControls enables FIPS access controls
	AccessControls bool
	// AdvancedAccessWorkflows enables advanced access workflows
	AdvancedAccessWorkflows bool
	// Cloud enables some cloud-related features
	Cloud bool
	// HSM enables PKCS#11 HSM support
	HSM bool
	// Desktop enables desktop access product
	Desktop bool
	// RecoveryCodes enables account recovery codes
	RecoveryCodes bool
}

Features provides supported and unsupported features

func (Features) ToProto

func (f Features) ToProto() *proto.Features

ToProto converts Features into proto.Features

type Modules

type Modules interface {
	// PrintVersion prints teleport version
	PrintVersion()
	// IsBoringBinary checks if the binary was compiled with BoringCrypto.
	IsBoringBinary() bool
	// Features returns supported features
	Features() Features
	// BuildType returns build type (OSS or Enterprise)
	BuildType() string
	// AttestHardwareKey attests a hardware key and returns its associated private key policy.
	AttestHardwareKey(context.Context, interface{}, keys.PrivateKeyPolicy, *keys.AttestationStatement, crypto.PublicKey, time.Duration) (keys.PrivateKeyPolicy, error)
	// EnableRecoveryCodes enables the usage of recovery codes for resetting forgotten passwords
	EnableRecoveryCodes()
}

Modules defines interface that external libraries can implement customizing default teleport behavior

func GetModules

func GetModules() Modules

GetModules returns the modules interface

type TestModules

type TestModules struct {
	// TestBuildType is returned from the BuiltType function.
	TestBuildType string
	// TestFeatures is returned from the Features function.
	TestFeatures Features

	MockAttestHardwareKey func(_ context.Context, _ interface{}, policy keys.PrivateKeyPolicy, _ *keys.AttestationStatement, _ crypto.PublicKey, _ time.Duration) (keys.PrivateKeyPolicy, error)
	// contains filtered or unexported fields
}

TestModules implements the Modules interface for testing.

Setting Test* fields will return those values from interface methods. IsBoringBinary and PrintVersion functions return the same values from default modules.

See SetTestModules for an example.

func (*TestModules) AttestHardwareKey

func (m *TestModules) AttestHardwareKey(ctx context.Context, obj interface{}, policy keys.PrivateKeyPolicy, as *keys.AttestationStatement, pk crypto.PublicKey, d time.Duration) (keys.PrivateKeyPolicy, error)

AttestHardwareKey attests a hardware key.

func (*TestModules) BuildType

func (m *TestModules) BuildType() string

BuildType returns build type (OSS or Enterprise).

func (*TestModules) EnableRecoveryCodes

func (p *TestModules) EnableRecoveryCodes()

EnableRecoveryCodes enables recovery codes. This is a noop since OSS teleport does not support recovery codes

func (*TestModules) Features

func (m *TestModules) Features() Features

Features returns supported features.

func (*TestModules) IsBoringBinary

func (m *TestModules) IsBoringBinary() bool

IsBoringBinary checks if the binary was compiled with BoringCrypto.

func (*TestModules) PrintVersion

func (m *TestModules) PrintVersion()

PrintVersion prints teleport version

Jump to

Keyboard shortcuts

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