config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 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

This section is empty.

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 Config

type Config struct {
	Maintenance   bool                `default:"false" desc:"if true, the node will start in maintenance mode"`
	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"`
	Web           WebConfig           `split_words:"true"`
	Node          TRISAConfig         `split_words:"true"`
	DirectorySync DirectorySyncConfig `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.

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 TRISAConfig

type TRISAConfig struct {
	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"`
	Pool                string          `split_words:"true" required:"false"`
	Certs               string          `split_words:"true" required:"false"`
	KeyExchangeCacheTTL time.Duration   `split_words:"true" default:"24h"`
	Directory           DirectoryConfig `split_words:"true"`
	// contains filtered or unexported fields
}

TRISAConfig is a generic configuration for the TRISA node options

func (*TRISAConfig) LoadCerts

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

LoadCerts returns the mtls TRISA 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 (*TRISAConfig) LoadPool

func (c *TRISAConfig) 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 (*TRISAConfig) Reset

func (c *TRISAConfig) 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

func (*TRISAConfig) Validate

func (c *TRISAConfig) Validate() error

Validate that the TRISA config has mTLS certificates for operation.

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"`
	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"`
	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