config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

Configuration

Configuration is managed using a TOML file. There are sets of configuration values for the server (e.g. which port to listen on), the services (e.g. which database to use), and each service.

Each service may define specific configuration, such as which DID methods are enabled for the DID service.

Usage

The service, upon boot, looks for a file called config.toml to find its configuration.

There are a number of configuration files in this directory provided as defaults. Specifically, config.toml is intended to be used when the service is run as a local go process. There is another file, compose.toml, which is intended to be used when the service is run via docker compose. To make this switch, it's recommended that one renames the file to config.toml and then maintains the original compose.toml file as local.toml or similar.

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath = "config/dev.toml"
	DefaultEnvPath    = "config/.env"
	Filename          = "dev.toml"
	ServiceName       = "ssi-service"
	Extension         = ".toml"

	DefaultServiceEndpoint = "http://localhost:8080"

	EnvironmentDev  Environment = "dev"
	EnvironmentTest Environment = "test"
	EnvironmentProd Environment = "prod"

	ConfigPath       EnvironmentVariable = "CONFIG_PATH"
	KeystorePassword EnvironmentVariable = "KEYSTORE_PASSWORD"
	DBPassword       EnvironmentVariable = "DB_PASSWORD"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseServiceConfig

type BaseServiceConfig struct {
	Name            string `toml:"name"`
	ServiceEndpoint string `toml:"service_endpoint"`
}

BaseServiceConfig represents configurable properties for a specific component of the SSI Service Can be wrapped and extended for any specific service config

type CredentialServiceConfig

type CredentialServiceConfig struct {
	*BaseServiceConfig
	// BatchCreateMaxItems set's the maximum amount that can be.
	BatchCreateMaxItems int `toml:"batch_create_max_items" conf:"default:100"`
}

func (*CredentialServiceConfig) IsEmpty

func (c *CredentialServiceConfig) IsEmpty() bool

type DIDServiceConfig

type DIDServiceConfig struct {
	*BaseServiceConfig
	Methods                  []string `toml:"methods"`
	LocalResolutionMethods   []string `toml:"local_resolution_methods"`
	UniversalResolverURL     string   `toml:"universal_resolver_url"`
	UniversalResolverMethods []string `toml:"universal_resolver_methods"`
	IONResolverURL           string   `toml:"ion_resolver_url"`
}

func (*DIDServiceConfig) IsEmpty

func (d *DIDServiceConfig) IsEmpty() bool

type Environment

type Environment string

type EnvironmentVariable

type EnvironmentVariable string

func (EnvironmentVariable) String

func (e EnvironmentVariable) String() string

type IssuanceServiceConfig

type IssuanceServiceConfig struct {
	*BaseServiceConfig
}

func (*IssuanceServiceConfig) IsEmpty

func (s *IssuanceServiceConfig) IsEmpty() bool

type KeyStoreServiceConfig

type KeyStoreServiceConfig struct {
	*BaseServiceConfig
	// Master key password. Used by a KDF whose key is used by a symmetric cypher for key encryption.
	// The password is salted before usage.
	// Note that this field is only used when MasterKeyURI is empty.
	MasterKeyPassword string `toml:"password"`

	// The URI for the master key. We use tink for envelope encryption as described in https://github.com/google/tink/blob/9bc2667963e20eb42611b7581e570f0dddf65a2b/docs/KEY-MANAGEMENT.md#key-management-with-tink
	// When left empty, then MasterKeyPassword is used.
	MasterKeyURI string `toml:"master_key_uri"`

	// Path for credentials. Required when using an external KMS. More info at https://github.com/google/tink/blob/9bc2667963e20eb42611b7581e570f0dddf65a2b/docs/KEY-MANAGEMENT.md#credentials
	KMSCredentialsPath string `toml:"kms_credentials_path"`
}

func (*KeyStoreServiceConfig) IsEmpty

func (k *KeyStoreServiceConfig) IsEmpty() bool

type ManifestServiceConfig

type ManifestServiceConfig struct {
	*BaseServiceConfig
	ExpirationDuration time.Duration `toml:"expiration_duration" conf:"default:30m"`
}

func (*ManifestServiceConfig) IsEmpty

func (m *ManifestServiceConfig) IsEmpty() bool

type OperationServiceConfig

type OperationServiceConfig struct {
	*BaseServiceConfig
}

func (*OperationServiceConfig) IsEmpty

func (o *OperationServiceConfig) IsEmpty() bool

type PresentationServiceConfig

type PresentationServiceConfig struct {
	*BaseServiceConfig
	ExpirationDuration time.Duration `toml:"expiration_duration" conf:"default:30m"`
}

func (*PresentationServiceConfig) IsEmpty

func (p *PresentationServiceConfig) IsEmpty() bool

type SSIServiceConfig

type SSIServiceConfig struct {
	conf.Version
	Server   ServerConfig   `toml:"server"`
	Services ServicesConfig `toml:"services"`
}

func LoadConfig

func LoadConfig(path string) (*SSIServiceConfig, error)

LoadConfig attempts to load a TOML config file from the given path, and coerce it into our object model. Before loading, defaults are applied on certain properties, which are overwritten if specified in the TOML file.

type SchemaServiceConfig

type SchemaServiceConfig struct {
	*BaseServiceConfig
}

func (*SchemaServiceConfig) IsEmpty

func (s *SchemaServiceConfig) IsEmpty() bool

type ServerConfig

type ServerConfig struct {
	Environment         Environment   `toml:"env" conf:"default:dev"`
	APIHost             string        `toml:"api_host" conf:"default:0.0.0.0:3000"`
	JagerHost           string        `toml:"jager_host" conf:"http://jaeger:14268/api/traces"`
	JagerEnabled        bool          `toml:"jager_enabled" conf:"default:false"`
	ReadTimeout         time.Duration `toml:"read_timeout" conf:"default:5s"`
	WriteTimeout        time.Duration `toml:"write_timeout" conf:"default:5s"`
	ShutdownTimeout     time.Duration `toml:"shutdown_timeout" conf:"default:5s"`
	LogLocation         string        `toml:"log_location" conf:"default:log"`
	LogLevel            string        `toml:"log_level" conf:"default:debug"`
	EnableSchemaCaching bool          `toml:"enable_schema_caching" conf:"default:true"`
	EnableAllowAllCORS  bool          `toml:"enable_allow_all_cors" conf:"default:false"`
}

ServerConfig represents configurable properties for the HTTP server

type ServicesConfig

type ServicesConfig struct {
	// at present, it is assumed that a single storage provider works for all services
	// in the future it may make sense to have per-service storage providers (e.g. mysql for one service,
	// mongo for another)
	StorageProvider string           `toml:"storage"`
	StorageOptions  []storage.Option `toml:"storage_option"`
	ServiceEndpoint string           `toml:"service_endpoint"`

	// Embed all service-specific configs here. The order matters: from which should be instantiated first, to last
	KeyStoreConfig        KeyStoreServiceConfig     `toml:"keystore,omitempty"`
	DIDConfig             DIDServiceConfig          `toml:"did,omitempty"`
	SchemaConfig          SchemaServiceConfig       `toml:"schema,omitempty"`
	CredentialConfig      CredentialServiceConfig   `toml:"credential,omitempty"`
	OperationConfig       OperationServiceConfig    `toml:"operation,omitempty"`
	PresentationConfig    PresentationServiceConfig `toml:"presentation,omitempty"`
	ManifestConfig        ManifestServiceConfig     `toml:"manifest,omitempty"`
	IssuanceServiceConfig IssuanceServiceConfig     `toml:"issuance,omitempty"`
	WebhookConfig         WebhookServiceConfig      `toml:"webhook,omitempty"`
}

ServicesConfig represents configurable properties for the components of the SSI Service

type WebhookServiceConfig

type WebhookServiceConfig struct {
	*BaseServiceConfig
	WebhookTimeout string `toml:"webhook_timeout"`
}

func (*WebhookServiceConfig) IsEmpty

func (p *WebhookServiceConfig) IsEmpty() bool

Jump to

Keyboard shortcuts

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