config

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "trisa"

All environment variables will have this prefix unless otherwise defined in struct tags. For example, the conf.LogLevel environment variable will be TRISA_LOG_LEVEL because of this prefix and the split_words struct tag in the conf below.

Variables

View Source
var (
	ErrMTLSPoolNotConfigured  = errors.New("invalid configuration: no certificate pool found")
	ErrMTLSCertsNotConfigured = errors.New("invalid configuration: no certificates found")
)

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Keys            map[string]string `required:"false" desc:"optional static key configuration as a map of keyID to path on disk"`
	Audience        string            `default:"http://localhost:8000" desc:"value for the aud jwt claim"`
	Issuer          string            `default:"http://localhost:8000" desc:"value for the iss jwt claim"`
	CookieDomain    string            `split_words:"true" default:"localhost" desc:"limit cookies to the specified domain (exclude port)"`
	AccessTokenTTL  time.Duration     `split_words:"true" default:"1h" desc:"the amount of time before an access token expires"`
	RefreshTokenTTL time.Duration     `split_words:"true" default:"2h" desc:"the amount of time before a refresh token expires"`
	TokenOverlap    time.Duration     `split_words:"true" default:"-15m" desc:"the amount of overlap between the access and refresh token"`
}

AuthConfig specifies the configuration for authenticating WebUI requests

type CertsCacheLoader added in v0.21.0

type CertsCacheLoader interface {
	Validate() error
	LoadCerts() (*trust.Provider, error)
	LoadPool() (trust.ProviderPool, error)
	Reset()
}

type Config

type Config struct {
	Maintenance   bool                `default:"false" desc:"if true, the node will start in maintenance mode"`
	Organization  string              `default:"Envoy" desc:"specify the name of the organization of the Envoy node for display purposes"`
	Mode          string              `default:"release" desc:"specify the mode of the server (release, debug, testing)"`
	LogLevel      logger.LevelDecoder `split_words:"true" default:"info" desc:"specify the verbosity of logging (trace, debug, info, warn, error, fatal panic)"`
	ConsoleLog    bool                `split_words:"true" default:"false" desc:"if true logs colorized human readable output instead of json"`
	DatabaseURL   string              `split_words:"true" default:"sqlite3:///trisa.db" desc:"dsn containing backend database configuration"`
	WebhookURL    string              `split_words:"true" desc:"specify a callback webhook that incoming travel rule messages will be posted to"`
	Web           WebConfig           `split_words:"true"`
	Node          TRISAConfig         `split_words:"true"`
	DirectorySync DirectorySyncConfig `split_words:"true"`
	TRP           TRPConfig           `split_words:"true"`
	RegionInfo    RegionInfo          `split_words:"true"`
	// contains filtered or unexported fields
}

Config contains all of the configuration parameters for the trisa node and is loaded from the environment or a configuration file with reasonable defaults for values that are omitted. The Config should be validated in preparation for running the server to ensure that all server operations work as expected.

func New

func New() (conf Config, err error)

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

func (Config) IsZero

func (c Config) IsZero() bool

Returns true if the config has not been correctly processed from the environment.

func (Config) Validate

func (c Config) Validate() (err error)

Custom validations are added here, particularly validations that require one or more fields to be processed before the validation occurs. NOTE: ensure that all nested config validation methods are called here.

func (Config) Webhook added in v0.24.0

func (c Config) Webhook() *url.URL

func (Config) WebhookEnabled added in v0.24.0

func (c Config) WebhookEnabled() bool

type DirectoryConfig

type DirectoryConfig struct {
	Insecure        bool   `default:"false" desc:"if true, do not connect using TLS"`
	Endpoint        string `default:"api.vaspdirectory.net:443" required:"true" desc:"the endpoint of the public GDS service"`
	MembersEndpoint string `` /* 126-byte string literal not displayed */
}

DirectoryConfig is a generic configuration for connecting to a TRISA GDS service. By default the configuration connects to the MainNet GDS, replace vaspdirectory.net with trisatest.net to connect to the TestNet instead.

func (DirectoryConfig) Network

func (c DirectoryConfig) Network() string

Network parses the directory service endpoint to identify the network of the directory.

type DirectorySyncConfig

type DirectorySyncConfig struct {
	Enabled  bool          `default:"true" desc:"if false, the sync background service will not be run"`
	Interval time.Duration `default:"6h" desc:"the interval synchronization is run"`
}

DirectorySyncConfig manages the behavior of synchronizing counterparty VASPs with the TRISA Global Directory Service (GDS).

type MTLSConfig added in v0.24.1

type MTLSConfig struct {
	Pool  string `required:"false" desc:"path to the x509 cert pool to use for mTLS connection authentication (optional)"`
	Certs string `` /* 131-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*MTLSConfig) LoadCerts added in v0.24.1

func (c *MTLSConfig) LoadCerts() (_ *trust.Provider, err error)

LoadCerts returns the mtls trust provider for setting up an mTLS 1.3 config. NOTE: this method is not thread-safe, ensure it is not used from multiple go-routines

func (*MTLSConfig) LoadPool added in v0.24.1

func (c *MTLSConfig) LoadPool() (_ trust.ProviderPool, err error)

LoadPool returns the mtls TRISA trust provider pool for creating an x509.Pool. NOTE: this method is not thread-safe, ensure it is not used from multiple go-routines

func (*MTLSConfig) Reset added in v0.24.1

func (c *MTLSConfig) Reset()

Reset the certs cache to force load the pool and certs again NOTE: this method is not thread-safe, ensure it is not used from multiple go-routines

type RegionInfo added in v0.17.0

type RegionInfo struct {
	ID      int32  `env:"REGION_INFO_ID" desc:"the 7 digit region identifier code"`
	Name    string `env:"REGION_INFO_NAME" desc:"the name of the region"`
	Country string `env:"REGION_INFO_COUNTRY" desc:"the alpha-2 country code of the region"`
	Cloud   string `env:"REGION_INFO_CLOUD" desc:"the cloud service provider"`
	Cluster string `env:"REGION_INFO_CLUSTER" desc:"the name of the cluster the node is hosted in"`
}

Optional region and deployment information associated with the node.

func (RegionInfo) Available added in v0.17.0

func (c RegionInfo) Available() bool

Determines if region info is available or not.

type TRISAConfig

type TRISAConfig struct {
	MTLSConfig
	Maintenance         bool            `env:"TRISA_MAINTENANCE" desc:"if true sets the TRISA node to maintenance mode; inherited from parent"`
	Endpoint            string          `env:"TRISA_ENDPOINT" desc:"trisa endpoint as assigned to the mTLS certificates for the trisa node"`
	Enabled             bool            `default:"true" desc:"if false, the TRISA node server will not be run"`
	BindAddr            string          `split_words:"true" default:":8100" desc:"the ip address and port to bind the trisa grpc server on"`
	KeyExchangeCacheTTL time.Duration   `split_words:"true" default:"24h"`
	Directory           DirectoryConfig `split_words:"true"`
}

TRISAConfig is a generic configuration for the TRISA node options

func (*TRISAConfig) Validate

func (c *TRISAConfig) Validate() error

Validate that the TRISA config has mTLS certificates for operation.

type TRPConfig added in v0.21.0

type TRPConfig struct {
	MTLSConfig
	Maintenance bool   `env:"TRISA_MAINTENANCE" desc:"if true sets the trp node to maintenance mode; inherited from parent"`
	Enabled     bool   `default:"true" desc:"if false, the trp server will not be run"`
	BindAddr    string `default:":8200" split_words:"true" desc:"the ip address and port to bind the trp server on"`
	UseMTLS     bool   `` /* 130-byte string literal not displayed */
	Identity    TRPIdentityConfig
}

func (*TRPConfig) Validate added in v0.21.0

func (c *TRPConfig) Validate() error

Validate that the TRP config is suitable for operation of the server

type TRPIdentityConfig added in v0.24.1

type TRPIdentityConfig struct {
	VASPName string `split_words:"true" desc:"specify the name response in a trp identity request"`
	LEI      string `required:"false" desc:"the lei of your vasp to respond to a trp identity request"`
}

type WebConfig

type WebConfig struct {
	Maintenance   bool       `env:"TRISA_MAINTENANCE" desc:"if true sets the web UI to maintenance mode; inherited from parent"`
	Enabled       bool       `default:"true" desc:"if false, the web UI server will not be run"`
	APIEnabled    bool       `` /* 136-byte string literal not displayed */
	UIEnabled     bool       `` /* 135-byte string literal not displayed */
	BindAddr      string     `default:":8000" split_words:"true" desc:"the ip address and port to bind the web server on"`
	Origin        string     `default:"http://localhost:8000" desc:"origin (url) of the web ui for creating endpoints and CORS access"`
	TRISAEndpoint string     `env:"TRISA_ENDPOINT" desc:"trisa endpoint as assigned to the mTLS certificates for the trisa node"`
	TRPEndpoint   string     `env:"TRISA_TRP_ENDPOINT" desc:"trp endpoint as assigned to the mTLS certificates for the trp node"`
	DocsName      string     `split_words:"true" desc:"the display name for the API docs server in the Swagger app"`
	Auth          AuthConfig `split_words:"true"`
}

WebConfig specifies the configuration for the web UI to manage the TRISA node and TRISA transactions. The web UI can be enabled or disabled and runs independently of the other servers on the node.

func (WebConfig) Validate

func (c WebConfig) Validate() (err error)

Jump to

Keyboard shortcuts

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