Documentation
¶
Overview ¶
Package config contains a centralized structure for all configuration options.
Index ¶
- func RegisterDatabaseFlags(v *viper.Viper, flags *pflag.FlagSet) error
- func RegisterServerFlags(v *viper.Viper, flags *pflag.FlagSet) error
- func SetViperDefaults(v *viper.Viper)
- type AuthConfig
- func (acfg *AuthConfig) GetAccessTokenPrivateKey() (*rsa.PrivateKey, error)
- func (acfg *AuthConfig) GetAccessTokenPublicKey() (*rsa.PublicKey, error)
- func (acfg *AuthConfig) GetRefreshTokenPrivateKey() (*rsa.PrivateKey, error)
- func (acfg *AuthConfig) GetRefreshTokenPublicKey() (*rsa.PublicKey, error)
- func (acfg *AuthConfig) GetTokenKey() ([]byte, error)
- type Config
- type CryptoConfig
- type DatabaseConfig
- type GRPCServerConfig
- type HTTPServerConfig
- type IdentityConfig
- type LoggingConfig
- type MetricServerConfig
- type MetricsConfig
- type TracingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDatabaseFlags ¶
RegisterDatabaseFlags registers the flags for the database configuration
func RegisterServerFlags ¶ added in v0.0.4
RegisterServerFlags registers the flags for the Mediator server
func SetViperDefaults ¶
SetViperDefaults sets the default values for the configuration to be picked up by viper
Types ¶
type AuthConfig ¶ added in v0.0.3
type AuthConfig struct {
// AccessTokenPrivateKey is the private key used to sign the access token for authn/z
AccessTokenPrivateKey string `mapstructure:"access_token_private_key" default:"./.ssh/access_token_rsa"`
// AccessTokenPublicKey is the public key used to verify the access token for authn/z
AccessTokenPublicKey string `mapstructure:"access_token_public_key" default:"./.ssh/access_token_rsa.pub"`
// RefreshTokenPrivateKey is the private key used to sign the refresh token for authn/z
RefreshTokenPrivateKey string `mapstructure:"refresh_token_private_key" default:"./.ssh/refresh_token_rsa"`
// RefreshTokenPublicKey is the public key used to verify the refresh token for authn/z
RefreshTokenPublicKey string `mapstructure:"refresh_token_public_key" default:"./.ssh/refresh_token_rsa.pub"`
// TokenExpiry is the expiry time for the access token in seconds
TokenExpiry int64 `mapstructure:"token_expiry" default:"3600"`
// RefreshExpiry is the expiry time for the refresh token in seconds
RefreshExpiry int64 `mapstructure:"refresh_expiry" default:"86400"`
// NoncePeriod is the period in seconds for which a nonce is valid
NoncePeriod int64 `mapstructure:"nonce_period" default:"3600"`
// TokenKey is the key used to store the provider's token in the database
TokenKey string `mapstructure:"token_key" default:"./.ssh/token_key_passphrase"`
}
AuthConfig is the configuration for the auth package
func (*AuthConfig) GetAccessTokenPrivateKey ¶ added in v0.0.4
func (acfg *AuthConfig) GetAccessTokenPrivateKey() (*rsa.PrivateKey, error)
GetAccessTokenPrivateKey returns the private key used to sign the access token
func (*AuthConfig) GetAccessTokenPublicKey ¶ added in v0.0.4
func (acfg *AuthConfig) GetAccessTokenPublicKey() (*rsa.PublicKey, error)
GetAccessTokenPublicKey returns the public key used to verify the access token
func (*AuthConfig) GetRefreshTokenPrivateKey ¶ added in v0.0.4
func (acfg *AuthConfig) GetRefreshTokenPrivateKey() (*rsa.PrivateKey, error)
GetRefreshTokenPrivateKey returns the private key used to sign the refresh token
func (*AuthConfig) GetRefreshTokenPublicKey ¶ added in v0.0.4
func (acfg *AuthConfig) GetRefreshTokenPublicKey() (*rsa.PublicKey, error)
GetRefreshTokenPublicKey returns the public key used to verify the refresh token
func (*AuthConfig) GetTokenKey ¶ added in v0.0.4
func (acfg *AuthConfig) GetTokenKey() ([]byte, error)
GetTokenKey returns a key used to encrypt the provider's token in the database
type Config ¶
type Config struct {
HTTPServer HTTPServerConfig `mapstructure:"http_server"`
GRPCServer GRPCServerConfig `mapstructure:"grpc_server"`
MetricServer MetricServerConfig `mapstructure:"metric_server"`
LoggingConfig LoggingConfig `mapstructure:"logging"`
Tracing TracingConfig `mapstructure:"tracing"`
Metrics MetricsConfig `mapstructure:"metrics"`
Database DatabaseConfig `mapstructure:"database"`
Identity IdentityConfig `mapstructure:"identity"`
Salt CryptoConfig `mapstructure:"salt"`
Auth AuthConfig `mapstructure:"auth"`
}
Config is the top-level configuration structure.
func DefaultConfigForTest ¶ added in v0.0.3
func DefaultConfigForTest() *Config
DefaultConfigForTest returns a configuration with all the struct defaults set, but no other changes.
type CryptoConfig ¶
type CryptoConfig struct {
Memory uint32 `mapstructure:"memory" default:"65536"`
Iterations uint32 `mapstructure:"iterations" default:"50"`
Parallelism uint `mapstructure:"parallelism" default:"4"`
SaltLength uint32 `mapstructure:"salt_length" default:"16"`
KeyLength uint32 `mapstructure:"key_length" default:"32"`
}
CryptoConfig is the configuration for the crypto package
type DatabaseConfig ¶
type DatabaseConfig struct {
Host string `mapstructure:"dbhost" default:"localhost"`
Port int `mapstructure:"dbport" default:"5432"`
User string `mapstructure:"dbuser" default:"postgres"`
Password string `mapstructure:"dbpass" default:"postgres"`
Name string `mapstructure:"dbname" default:"mediator"`
SSLMode string `mapstructure:"sslmode" default:"disable"`
// If set, use credentials from the specified cloud provider.
// Currently supported values are `aws`
CloudProviderCredentials string `mapstructure:"cloud_provider_credentials"`
AWSRegion string `mapstructure:"aws_region"`
// contains filtered or unexported fields
}
DatabaseConfig is the configuration for the database
func (*DatabaseConfig) GetDBConnection ¶
GetDBConnection returns a connection to the database
type GRPCServerConfig ¶
type GRPCServerConfig struct {
// Host is the host to bind to
Host string `mapstructure:"host" default:"127.0.0.1"`
// Port is the port to bind to
Port int `mapstructure:"port" default:"8090"`
}
GRPCServerConfig is the configuration for the gRPC server
func (*GRPCServerConfig) GetAddress ¶
func (s *GRPCServerConfig) GetAddress() string
GetAddress returns the address to bind to
type HTTPServerConfig ¶
type HTTPServerConfig struct {
// Host is the host to bind to
Host string `mapstructure:"host" default:"127.0.0.1"`
// Port is the port to bind to
Port int `mapstructure:"port" default:"8080"`
}
HTTPServerConfig is the configuration for the HTTP server
func (*HTTPServerConfig) GetAddress ¶
func (s *HTTPServerConfig) GetAddress() string
GetAddress returns the address to bind to
type IdentityConfig ¶ added in v0.0.4
type IdentityConfig struct {
// IssuerUrl is the base URL where the identity server is running
IssuerUrl string `mapstructure:"issuer_url" default:"http://localhost:8081"`
// Realm is the Keycloak realm that the client belongs to
Realm string `mapstructure:"realm" default:"stacklok"`
// ClientId is the client ID that identifies the mediator CLI
ClientId string `mapstructure:"client_id" default:"mediator-cli"`
}
IdentityConfig is the configuration for the identity provider
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level" default:"debug"`
Format string `mapstructure:"format" default:"json"`
LogFile string `mapstructure:"logFile" default:""`
}
LoggingConfig is the configuration for the logging package
type MetricServerConfig ¶ added in v0.0.4
type MetricServerConfig struct {
// Host is the host to bind to
Host string `mapstructure:"host" default:"127.0.0.1"`
// Port is the port to bind to
Port int `mapstructure:"port" default:"9090"`
}
MetricServerConfig is the configuration for the metric server
func (*MetricServerConfig) GetAddress ¶ added in v0.0.4
func (s *MetricServerConfig) GetAddress() string
GetAddress returns the address to bind to
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `mapstructure:"enabled" default:"true"`
}
MetricsConfig is the configuration for the metrics
type TracingConfig ¶
type TracingConfig struct {
Enabled bool `mapstructure:"enabled" default:"false"`
// for the demonstration, we use AlwaysSmaple sampler to take all spans.
// do not use this option in production.
SampleRatio float64 `mapstructure:"sample_ratio" default:"0.1"`
}
TracingConfig is the configuration for our tracing capabilities