config

package
v0.0.0-...-ef7a112 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath = ""
	Filename          = "dev.toml"
	Extension         = ".toml"

	ServiceResourceuser  ServiceID = "resourceuser"
	ServiceResourceowner ServiceID = "resourceowner"
	ServiceIssuer        ServiceID = "issuer"
)
View Source
const (
	EnvironmentDev  Environment = "dev"
	EnvironmentTest Environment = "test"
	EnvironmentProd Environment = "prod"

	DefaultEnvPath = "config/.env"

	EnvPath       EnvironmentVariable = "ENV_PATH"
	ConfigPath    EnvironmentVariable = "CONFIG_PATH"
	FileStorePath EnvironmentVariable = "FILESTORE_PATH"
	DBPassword    EnvironmentVariable = "DB_PASSWORD"
)
View Source
const (
	ServiceName    = "onchain-access-control"
	ServiceVersion = "0.0.3"
	APIVersion     = "v1"
)

Variables

This section is empty.

Functions

func Description

func Description() string

func GetAPIBase

func GetAPIBase() string

func GetFileStoreBase

func GetFileStoreBase() string

func GetServicePath

func GetServicePath(service framework.Type) string

func GetStatusBase

func GetStatusBase() string

func LoadEnv

func LoadEnv() (string, error)

LoadEnv finds the appropriate env file to use for the service and configures the environment with the configured input file.

func Name

func Name() string

func SetAPIBase

func SetAPIBase(url string)

func SetFileStoreBase

func SetFileStoreBase(path string)

func SetServicePath

func SetServicePath(service framework.Type, path string)

func SetStatusBase

func SetStatusBase(url string)

Types

type AuthServiceConfig

type AuthServiceConfig struct {
	EncryptionConfig
}

type CredentialServiceConfig

type CredentialServiceConfig struct {
	// BatchCreateMaxItems set's the maximum amount of credentials that can be created in a single request.
	BatchCreateMaxItems int `toml:"batch_create_max_items" conf:"default:100"`
	// BatchUpdateStatusMaxItems set's the maximum amount of credentials statuses that can be updated in a single request.
	BatchUpdateStatusMaxItems int `toml:"batch_update_status_max_items" conf:"default:100"`
}

func (*CredentialServiceConfig) IsEmpty

func (c *CredentialServiceConfig) IsEmpty() bool

type DIDServiceConfig

type DIDServiceConfig struct {
	Methods                  []string `toml:"methods" conf:"default:key;web"`
	LocalResolutionMethods   []string `toml:"local_resolution_methods" conf:"default:key;peer;web;jwk;pkh"`
	UniversalResolverURL     string   `toml:"universal_resolver_url"`
	UniversalResolverMethods []string `toml:"universal_resolver_methods"`
	IONResolverURL           string   `toml:"ion_resolver_url"`
	// BatchCreateMaxItems set's the maximum amount that can be.
	BatchCreateMaxItems int `toml:"batch_create_max_items" conf:"default:100"`
}

func (*DIDServiceConfig) IsEmpty

func (d *DIDServiceConfig) IsEmpty() bool

type EncryptionConfig

type EncryptionConfig struct {
	DisableEncryption bool `toml:"disable_encryption" conf:"default:false"`

	// The URI for a 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 and DisableEncryption is off, then a random key is generated and used. This random key is persisted unencrypted in the
	// configured storage. Production deployments should never leave this field empty.
	MasterKeyURI string `toml:"master_key_uri"`

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

func (EncryptionConfig) EncryptionEnabled

func (e EncryptionConfig) EncryptionEnabled() bool

func (EncryptionConfig) GetKMSCredentialsPath

func (e EncryptionConfig) GetKMSCredentialsPath() string

func (EncryptionConfig) GetMasterKeyURI

func (e EncryptionConfig) GetMasterKeyURI() string

type Environment

type Environment string

type EnvironmentVariable

type EnvironmentVariable string

func (EnvironmentVariable) String

func (e EnvironmentVariable) String() string

type FileStoreServiceConfig

type FileStoreServiceConfig struct {
	// Path to static files. WIll be set by environment variable. Required.
	LocalPath string `toml:"local_path"`

	// Server entrypoint for directory listing.
	EndpointPrefix string `toml:"endpoint_prefix" conf:"default:static"`
}

type KeyStoreServiceConfig

type KeyStoreServiceConfig struct {
	EncryptionConfig
}

func (*KeyStoreServiceConfig) EncryptionEnabled

func (k *KeyStoreServiceConfig) EncryptionEnabled() bool

func (*KeyStoreServiceConfig) GetKMSCredentialsPath

func (k *KeyStoreServiceConfig) GetKMSCredentialsPath() string

func (*KeyStoreServiceConfig) GetMasterKeyURI

func (k *KeyStoreServiceConfig) GetMasterKeyURI() string

func (*KeyStoreServiceConfig) IsEmpty

func (k *KeyStoreServiceConfig) IsEmpty() bool

type OACServiceConfig

type OACServiceConfig struct {
	Server   ServerConfig   `toml:"server"`
	Services ServicesConfig `toml:"services"`
}

func Init

func Init() *OACServiceConfig

func LoadConfig

func LoadConfig() (*OACServiceConfig, 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 ServerConfig

type ServerConfig struct {
	Environment         Environment   `toml:"env" conf:"default:dev"`
	Service             ServiceID     `toml:"service" conf:"default:resourceuser"`
	APIHost             string        `toml:"api_host" conf:"default:0.0.0.0:3000"`
	JagerHost           string        `toml:"jager_host" conf:"default: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 ServiceID

type ServiceID string

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" conf:"default:bolt"`
	StorageOptions  []storage.Option `toml:"storage_option"`
	ServiceEndpoint string           `toml:"service_endpoint" conf:"default:http://localhost:8080"`
	StatusEndpoint  string           `toml:"status_endpoint"`

	// Application level encryption configuration. Defines how values are encrypted before they are stored in the
	// configured KV store.
	AppLevelEncryptionConfiguration EncryptionConfig `toml:"storage_encryption,omitempty"`

	// Embed all service-specific configs here. The order matters: from which should be instantiated first, to last
	AuthConfig       AuthServiceConfig       `toml:"auth,omitempty"`
	KeyStoreConfig   KeyStoreServiceConfig   `toml:"keystore,omitempty"`
	FileStoreConfig  FileStoreServiceConfig  `toml:"filestore,omitempty"`
	DIDConfig        DIDServiceConfig        `toml:"did,omitempty"`
	CredentialConfig CredentialServiceConfig `toml:"credential,omitempty"`
}

ServicesConfig represents configurable properties for the components of the OAC service

Jump to

Keyboard shortcuts

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