Documentation
¶
Overview ¶
Package config defines the environment baased configuration for this project. Each server has a unique config type.
Index ¶
- func ProcessWith(ctx context.Context, spec Validatable, l envconfig.Lookuper) error
- type APIServerConfig
- type AdminAPIServerConfig
- func (c *AdminAPIServerConfig) GetAllowedSymptomAge() time.Duration
- func (c *AdminAPIServerConfig) GetCollisionRetryCount() uint
- func (c *AdminAPIServerConfig) GetVerificationCodeDigits() uint
- func (c *AdminAPIServerConfig) GetVerificationCodeDuration() time.Duration
- func (c *AdminAPIServerConfig) ObservabilityExporterConfig() *observability.Config
- func (c *AdminAPIServerConfig) Validate() error
- type Base64ByteSlice
- type CleanupConfig
- type FirebaseConfig
- type IssueAPIConfig
- type ServerConfig
- func (c *ServerConfig) FirebaseConfig() *firebase.Config
- func (c *ServerConfig) GetAllowedSymptomAge() time.Duration
- func (c *ServerConfig) GetCollisionRetryCount() uint
- func (c *ServerConfig) GetVerificationCodeDigits() uint
- func (c *ServerConfig) GetVerificationCodeDuration() time.Duration
- func (c *ServerConfig) ObservabilityExporterConfig() *observability.Config
- func (c *ServerConfig) Validate() error
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessWith ¶
ProcessWith creates a new config with the given lookuper for parsing config.
Types ¶
type APIServerConfig ¶
type APIServerConfig struct {
Database database.Config
Observability observability.Config
// DevMode produces additional debugging information. Do not enable in
// production environments.
DevMode bool `env:"DEV_MODE"`
Port string `env:"PORT,default=8080"`
APIKeyCacheDuration time.Duration `env:"API_KEY_CACHE_DURATION,default=5m"`
// Verification Token Config
// Currently this does not easily support rotation. TODO(mikehelmick) - add support.
VerificationTokenDuration time.Duration `env:"VERIFICATION_TOKEN_DURATION,default=24h"`
TokenSigningKey string `env:"TOKEN_SIGNING_KEY,required"`
TokenSigningKeyID string `env:"TOKEN_SIGNING_KEY_ID,default=v1"`
TokenIssuer string `env:"TOKEN_ISSUER,default=diagnosis-verification-example"`
// Verification certificate config
PublicKeyCacheDuration time.Duration `env:"PUBLIC_KEY_CACHE_DURATION,default=15m"`
CertificateSigningKey string `env:"CERTIFICATE_SIGNING_KEY,required"`
CertificateSigningKeyID string `env:"CERTIFICATE_SIGNING_KEY_ID,default=v1"`
CertificateIssuer string `env:"CERTIFICATE_ISSUER,default=diagnosis-verification-example"`
CertificateAudience string `env:"CERTIFICATE_AUDIENCE,default=exposure-notifications-server"`
CertificateDuration time.Duration `env:"CERTIFICATE_DURATION,default=15m"`
// Rate limiting configuration
RateLimit ratelimit.Config
}
APIServerConfig represnets the environment based configuration for the API server.
func NewAPIServerConfig ¶
func NewAPIServerConfig(ctx context.Context) (*APIServerConfig, error)
NewAPIServerConfig returns the environment config for the API server. Only needs to be called once per instance, but may be called multiple times.
func (*APIServerConfig) ObservabilityExporterConfig ¶ added in v0.3.0
func (c *APIServerConfig) ObservabilityExporterConfig() *observability.Config
func (*APIServerConfig) Validate ¶
func (c *APIServerConfig) Validate() error
type AdminAPIServerConfig ¶
type AdminAPIServerConfig struct {
Database database.Config
Observability observability.Config
// DevMode produces additional debugging information. Do not enable in
// production environments.
DevMode bool `env:"DEV_MODE"`
Port string `env:"PORT,default=8080"`
RateLimit uint64 `env:"RATE_LIMIT,default=60"`
APIKeyCacheDuration time.Duration `env:"API_KEY_CACHE_DURATION,default=5m"`
CodeDuration time.Duration `env:"CODE_DURATION,default=1h"`
CodeDigits uint `env:"CODE_DIGITS,default=8"`
CollisionRetryCount uint `env:"COLLISION_RETRY_COUNT,default=6"`
AllowedSymptomAge time.Duration `env:"ALLOWED_PAST_SYMPTOM_DAYS,default=336h"` // 336h is 14 days.
}
AdminAPIServerConfig represents the environment based config for the Admin API Server.
func NewAdminAPIServerConfig ¶
func NewAdminAPIServerConfig(ctx context.Context) (*AdminAPIServerConfig, error)
NewAdminAPIServerConfig returns the environment config for the Admin API server. Only needs to be called once per instance, but may be called multiple times.
func (*AdminAPIServerConfig) GetAllowedSymptomAge ¶
func (c *AdminAPIServerConfig) GetAllowedSymptomAge() time.Duration
func (*AdminAPIServerConfig) GetCollisionRetryCount ¶ added in v0.3.0
func (c *AdminAPIServerConfig) GetCollisionRetryCount() uint
func (*AdminAPIServerConfig) GetVerificationCodeDigits ¶ added in v0.3.0
func (c *AdminAPIServerConfig) GetVerificationCodeDigits() uint
func (*AdminAPIServerConfig) GetVerificationCodeDuration ¶
func (c *AdminAPIServerConfig) GetVerificationCodeDuration() time.Duration
func (*AdminAPIServerConfig) ObservabilityExporterConfig ¶ added in v0.3.0
func (c *AdminAPIServerConfig) ObservabilityExporterConfig() *observability.Config
func (*AdminAPIServerConfig) Validate ¶
func (c *AdminAPIServerConfig) Validate() error
type Base64ByteSlice ¶
type Base64ByteSlice []envconfig.Base64Bytes
Base64ByteSlice is a slice of base64-encoded strings that we want to convert to bytes.
func (Base64ByteSlice) AsBytes ¶
func (c Base64ByteSlice) AsBytes() [][]byte
AsBytes returns the value as a slice of bytes instead of its main type.
type CleanupConfig ¶
type CleanupConfig struct {
Database database.Config
Observability observability.Config
// DevMode produces additional debugging information. Do not enable in
// production environments.
DevMode bool `env:"DEV_MODE"`
Port string `env:"PORT,default=8080"`
RateLimit uint64 `env:"RATE_LIMIT,default=60"`
// Cleanup config
CleanupPeriod time.Duration `env:"CLEANUP_PERIOD,default=15m"`
VerificationCodeMaxAge time.Duration `env:"VERIFICATION_CODE_MAX_AGE,default=24h"`
VerificationTokenMaxAge time.Duration `env:"VERIFICATION_TOKEN_MAX_AGE,default=24h"`
}
CleanupConfig represents the environment based configuration for the Cleanup server.
func NewCleanupConfig ¶
func NewCleanupConfig(ctx context.Context) (*CleanupConfig, error)
NewCleanupConfig returns the environment config for the cleanup server. Only needs to be called once per instance, but may be called multiple times.
func (*CleanupConfig) ObservabilityExporterConfig ¶ added in v0.3.0
func (c *CleanupConfig) ObservabilityExporterConfig() *observability.Config
func (*CleanupConfig) Validate ¶
func (c *CleanupConfig) Validate() error
type FirebaseConfig ¶
type FirebaseConfig struct {
APIKey string `env:"FIREBASE_API_KEY,required"`
AuthDomain string `env:"FIREBASE_AUTH_DOMAIN,required"`
DatabaseURL string `env:"FIREBASE_DATABASE_URL,required"`
ProjectID string `env:"FIREBASE_PROJECT_ID,required"`
StorageBucket string `env:"FIREBASE_STORAGE_BUCKET,required"`
MessageSenderID string `env:"FIREBASE_MESSAGE_SENDER_ID,required"`
AppID string `env:"FIREBASE_APP_ID,required"`
MeasurementID string `env:"FIREBASE_MEASUREMENT_ID,required"`
}
FirebaseConfig represents configuration specific to firebase auth.
type IssueAPIConfig ¶
type IssueAPIConfig interface {
GetCollisionRetryCount() uint
GetAllowedSymptomAge() time.Duration
GetVerificationCodeDuration() time.Duration
GetVerificationCodeDigits() uint
}
IssueAPIConfig is an interface that represents what is needed of the verification code issue API.
type ServerConfig ¶
type ServerConfig struct {
Firebase FirebaseConfig
Database database.Config
Observability observability.Config
Port string `env:"PORT,default=8080"`
// Login Config
SessionDuration time.Duration `env:"SESSION_DURATION,default=24h"`
RevokeCheckPeriod time.Duration `env:"REVOKE_CHECK_DURATION,default=5m"`
// CookieKeys is a slice of bytes. The odd values are hash keys to HMAC the
// cookies. The even values are block keys to encrypt the cookie. Both keys
// should be 64 bytes. The value's should be specified as base64 encoded.
CookieKeys Base64ByteSlice `env:"COOKIE_KEYS,required"`
// CookieDomain is the domain for which cookie should be valid.
CookieDomain string `env:"COOKIE_DOMAIN"`
// CSRFAuthKey is the authentication key. It must be 32-bytes and can be
// generated with tools/gen-secret. The value's should be base64 encoded.
CSRFAuthKey envconfig.Base64Bytes `env:"CSRF_AUTH_KEY,required"`
// Application Config
ServerName string `env:"SERVER_NAME,default=Diagnosis Verification Server"`
CodeDuration time.Duration `env:"CODE_DURATION,default=1h"`
CodeDigits uint `env:"CODE_DIGITS,default=8"`
CollisionRetryCount uint `env:"COLLISION_RETRY_COUNT,default=6"`
AllowedSymptomAge time.Duration `env:"ALLOWED_PAST_SYMPTOM_DAYS,default=336h"` // 336h is 14 days.
AssetsPath string `env:"ASSETS_PATH,default=./cmd/server/assets"`
// If Dev mode is true, cookies aren't required to be sent over secure channels.
// This includes CSRF protection base cookie. You want this false in production (the default).
DevMode bool `env:"DEV_MODE"`
// Rate limiting configuration
RateLimit ratelimit.Config
}
ServerConfig represents the environment based config for the server.
func NewServerConfig ¶
func NewServerConfig(ctx context.Context) (*ServerConfig, error)
NewServerConfig initializes and validates a ServerConfig struct.
func (*ServerConfig) FirebaseConfig ¶
func (c *ServerConfig) FirebaseConfig() *firebase.Config
FirebaseConfig returns the firebase SDK config based on the local env config.
func (*ServerConfig) GetAllowedSymptomAge ¶
func (c *ServerConfig) GetAllowedSymptomAge() time.Duration
func (*ServerConfig) GetCollisionRetryCount ¶ added in v0.3.0
func (c *ServerConfig) GetCollisionRetryCount() uint
func (*ServerConfig) GetVerificationCodeDigits ¶ added in v0.3.0
func (c *ServerConfig) GetVerificationCodeDigits() uint
func (*ServerConfig) GetVerificationCodeDuration ¶
func (c *ServerConfig) GetVerificationCodeDuration() time.Duration
func (*ServerConfig) ObservabilityExporterConfig ¶ added in v0.3.0
func (c *ServerConfig) ObservabilityExporterConfig() *observability.Config
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable indicates that a type can be validated.