config

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationCleanupSchedule added in v1.16.0

type AuthenticationCleanupSchedule struct {
	Interval    time.Duration `json:"interval,omitempty" mapstructure:"interval"`
	GracePeriod time.Duration `json:"gracePeriod,omitempty" mapstructure:"grace_period"`
}

AuthenticationCleanupSchedule is used to configure a cleanup goroutine.

type AuthenticationConfig added in v1.15.0

type AuthenticationConfig struct {
	// Required designates whether authentication credentials are validated.
	// If required == true, then authentication is required for all API endpoints.
	// Else, authentication is not required and Flipt's APIs are not secured.
	Required bool `json:"required,omitempty" mapstructure:"required"`

	Session AuthenticationSession `json:"session,omitempty" mapstructure:"session"`
	Methods AuthenticationMethods `json:"methods,omitempty" mapstructure:"methods"`
}

AuthenticationConfig configures Flipts authentication mechanisms

func (AuthenticationConfig) ShouldRunCleanup added in v1.16.0

func (c AuthenticationConfig) ShouldRunCleanup() (shouldCleanup bool)

ShouldRunCleanup returns true if the cleanup background process should be started. It returns true given at-least 1 method is enabled and it's associated schedule has been configured (non-nil).

type AuthenticationMethod added in v1.17.0

type AuthenticationMethod[C AuthenticationMethodInfoProvider] struct {
	Method  C                              `mapstructure:",squash"`
	Enabled bool                           `json:"enabled,omitempty" mapstructure:"enabled"`
	Cleanup *AuthenticationCleanupSchedule `json:"cleanup,omitempty" mapstructure:"cleanup"`
}

AuthenticationMethod is a container for authentication methods. It describes the common properties of all authentication methods. Along with leaving a generic slot for the particular method to declare its own structural fields. This generic field (Method) must implement the AuthenticationMethodInfoProvider to be valid at compile time.

func (AuthenticationMethod[C]) Info added in v1.17.0

type AuthenticationMethodInfo added in v1.17.0

type AuthenticationMethodInfo struct {
	Method            auth.Method
	SessionCompatible bool
	Metadata          map[string]string
}

AuthenticationMethodInfo is a structure which describes properties of a particular authentication method. i.e. the name and whether or not the method is session compatible.

func (AuthenticationMethodInfo) Name added in v1.17.0

Name returns the friendly lower-case name for the authentication method.

type AuthenticationMethodInfoProvider added in v1.17.0

type AuthenticationMethodInfoProvider interface {
	Info() AuthenticationMethodInfo
}

AuthenticationMethodInfoProvider is a type with a single method Info which returns an AuthenticationMethodInfo describing the underlying methods properties.

type AuthenticationMethodOIDCConfig added in v1.17.0

type AuthenticationMethodOIDCConfig struct {
	Providers map[string]AuthenticationMethodOIDCProvider `json:"providers,omitempty" mapstructure:"providers"`
}

AuthenticationMethodOIDCConfig configures the OIDC authentication method. This method can be used to establish browser based sessions.

func (AuthenticationMethodOIDCConfig) Info added in v1.17.0

Info describes properties of the authentication method "oidc".

type AuthenticationMethodOIDCProvider added in v1.17.0

type AuthenticationMethodOIDCProvider struct {
	IssuerURL       string   `json:"issuerURL,omitempty" mapstructure:"issuer_url"`
	ClientID        string   `json:"clientID,omitempty" mapstructure:"client_id"`
	ClientSecret    string   `json:"clientSecret,omitempty" mapstructure:"client_secret"`
	RedirectAddress string   `json:"redirectAddress,omitempty" mapstructure:"redirect_address"`
	Scopes          []string `json:"scopes,omitempty" mapstructure:"scopes"`
}

AuthenticationOIDCProvider configures provider credentials

type AuthenticationMethodTokenConfig added in v1.15.0

type AuthenticationMethodTokenConfig struct{}

AuthenticationMethodTokenConfig contains fields used to configure the authentication method "token". This authentication method supports the ability to create static tokens via the /auth/v1/method/token prefix of endpoints.

func (AuthenticationMethodTokenConfig) Info added in v1.17.0

Info describes properties of the authentication method "token".

type AuthenticationMethods added in v1.16.0

type AuthenticationMethods struct {
	Token AuthenticationMethod[AuthenticationMethodTokenConfig] `json:"token,omitempty" mapstructure:"token"`
	OIDC  AuthenticationMethod[AuthenticationMethodOIDCConfig]  `json:"oidc,omitempty" mapstructure:"oidc"`
}

AuthenticationMethods is a set of configuration for each authentication method available for use within Flipt.

func (AuthenticationMethods) AllMethods added in v1.17.0

AllMethods returns all the AuthenticationMethod instances available.

type AuthenticationSession added in v1.17.0

type AuthenticationSession struct {
	// Domain is the domain on which to register session cookies.
	Domain string `json:"domain,omitempty" mapstructure:"domain"`
	// Secure sets the secure property (i.e. HTTPS only) on both the state and token cookies.
	Secure bool `json:"secure" mapstructure:"secure"`
	// TokenLifetime is the duration of the flipt client token generated once
	// authentication has been established via a session compatible method.
	TokenLifetime time.Duration `json:"tokenLifetime,omitempty" mapstructure:"token_lifetime"`
	// StateLifetime is the lifetime duration of the state cookie.
	StateLifetime time.Duration `json:"stateLifetime,omitempty" mapstructure:"state_lifetime"`
	// CSRF configures CSRF provention mechanisms.
	CSRF AuthenticationSessionCSRF `json:"csrf,omitempty" mapstructure:"csrf"`
}

AuthenticationSession configures the session produced for browsers when establishing authentication via HTTP.

type AuthenticationSessionCSRF added in v1.17.0

type AuthenticationSessionCSRF struct {
	// Key is the private key string used to authenticate csrf tokens.
	Key string `json:"-" mapstructure:"key"`
}

AuthenticationSessionCSRF configures cross-site request forgery prevention.

type CacheBackend

type CacheBackend uint8

CacheBackend is either memory or redis

const (

	// CacheMemory ...
	CacheMemory CacheBackend
	// CacheRedis ...
	CacheRedis
)

func (CacheBackend) MarshalJSON

func (c CacheBackend) MarshalJSON() ([]byte, error)

func (CacheBackend) String

func (c CacheBackend) String() string

type CacheConfig

type CacheConfig struct {
	Enabled bool              `json:"enabled" mapstructure:"enabled"`
	TTL     time.Duration     `json:"ttl,omitempty" mapstructure:"ttl"`
	Backend CacheBackend      `json:"backend,omitempty" mapstructure:"backend"`
	Memory  MemoryCacheConfig `json:"memory,omitempty" mapstructure:"memory"`
	Redis   RedisCacheConfig  `json:"redis,omitempty" mapstructure:"redis"`
}

CacheConfig contains fields, which enable and configure Flipt's various caching mechanisms.

Currently, flipt support in-memory and redis backed caching.

type Config

type Config struct {
	Version        string               `json:"version,omitempty"`
	Log            LogConfig            `json:"log,omitempty" mapstructure:"log"`
	UI             UIConfig             `json:"ui,omitempty" mapstructure:"ui"`
	Cors           CorsConfig           `json:"cors,omitempty" mapstructure:"cors"`
	Cache          CacheConfig          `json:"cache,omitempty" mapstructure:"cache"`
	Server         ServerConfig         `json:"server,omitempty" mapstructure:"server"`
	Tracing        TracingConfig        `json:"tracing,omitempty" mapstructure:"tracing"`
	Database       DatabaseConfig       `json:"db,omitempty" mapstructure:"db"`
	Meta           MetaConfig           `json:"meta,omitempty" mapstructure:"meta"`
	Authentication AuthenticationConfig `json:"authentication,omitempty" mapstructure:"authentication"`
}

Config contains all of Flipts configuration needs.

The root of this structure contains a collection of sub-configuration categories.

Each sub-configuration (e.g. LogConfig) optionally implements either or both of the defaulter or validator interfaces. Given the sub-config implements a `setDefaults(*viper.Viper) []string` method then this will be called with the viper context before unmarshalling. This allows the sub-configuration to set any appropriate defaults. Given the sub-config implements a `validate() error` method then this will be called after unmarshalling, such that the function can emit any errors derived from the resulting state of the configuration.

func (*Config) ServeHTTP

func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CorsConfig

type CorsConfig struct {
	Enabled        bool     `json:"enabled" mapstructure:"enabled"`
	AllowedOrigins []string `json:"allowedOrigins,omitempty" mapstructure:"allowed_origins"`
}

CorsConfig contains fields, which configure behaviour in the HTTPServer relating to the CORS header-based mechanisms.

type DatabaseConfig

type DatabaseConfig struct {
	URL             string           `json:"url,omitempty" mapstructure:"url"`
	MaxIdleConn     int              `json:"maxIdleConn,omitempty" mapstructure:"max_idle_conn"`
	MaxOpenConn     int              `json:"maxOpenConn,omitempty" mapstructure:"max_open_conn"`
	ConnMaxLifetime time.Duration    `json:"connMaxLifetime,omitempty" mapstructure:"conn_max_lifetime"`
	Name            string           `json:"name,omitempty" mapstructure:"name"`
	User            string           `json:"user,omitempty" mapstructure:"user"`
	Password        string           `json:"password,omitempty" mapstructure:"password"`
	Host            string           `json:"host,omitempty" mapstructure:"host"`
	Port            int              `json:"port,omitempty" mapstructure:"port"`
	Protocol        DatabaseProtocol `json:"protocol,omitempty" mapstructure:"protocol"`
}

DatabaseConfig contains fields, which configure the various relational database backends.

Flipt currently supports SQLite, Postgres and MySQL backends.

type DatabaseProtocol

type DatabaseProtocol uint8

DatabaseProtocol represents a database protocol

const (

	// DatabaseSQLite ...
	DatabaseSQLite DatabaseProtocol
	// DatabasePostgres ...
	DatabasePostgres
	// DatabaseMySQL ...
	DatabaseMySQL
	// DatabaseCockroachDB ...
	DatabaseCockroachDB
)

func (DatabaseProtocol) MarshalJSON

func (d DatabaseProtocol) MarshalJSON() ([]byte, error)

func (DatabaseProtocol) String

func (d DatabaseProtocol) String() string

type JaegerTracingConfig

type JaegerTracingConfig struct {
	Enabled bool   `json:"enabled,omitempty" mapstructure:"enabled"`
	Host    string `json:"host,omitempty" mapstructure:"host"`
	Port    int    `json:"port,omitempty" mapstructure:"port"`
}

JaegerTracingConfig contains fields, which configure specifically Jaeger span and tracing output destination.

type LogConfig

type LogConfig struct {
	Level     string      `json:"level,omitempty" mapstructure:"level"`
	File      string      `json:"file,omitempty" mapstructure:"file"`
	Encoding  LogEncoding `json:"encoding,omitempty" mapstructure:"encoding"`
	GRPCLevel string      `json:"grpcLevel,omitempty" mapstructure:"grpc_level"`
}

LogConfig contains fields which control, direct and filter the logging telemetry produces by Flipt.

type LogEncoding

type LogEncoding uint8

LogEncoding is either console or JSON

const (
	LogEncodingConsole LogEncoding
	LogEncodingJSON
)

func (LogEncoding) MarshalJSON

func (e LogEncoding) MarshalJSON() ([]byte, error)

func (LogEncoding) String

func (e LogEncoding) String() string

type MemoryCacheConfig

type MemoryCacheConfig struct {
	EvictionInterval time.Duration `json:"evictionInterval,omitempty" mapstructure:"eviction_interval"`
}

MemoryCacheConfig contains fields, which configure in-memory caching.

type MetaConfig

type MetaConfig struct {
	CheckForUpdates  bool   `json:"checkForUpdates" mapstructure:"check_for_updates"`
	TelemetryEnabled bool   `json:"telemetryEnabled" mapstructure:"telemetry_enabled"`
	StateDirectory   string `json:"stateDirectory" mapstructure:"state_directory"`
}

MetaConfig contains a variety of meta configuration fields.

type RedisCacheConfig

type RedisCacheConfig struct {
	Host     string `json:"host,omitempty" mapstructure:"host"`
	Port     int    `json:"port,omitempty" mapstructure:"port"`
	Password string `json:"password,omitempty" mapstructure:"password"`
	DB       int    `json:"db,omitempty" mapstructure:"db"`
}

RedisCacheConfig contains fields, which configure the connection credentials for redis backed caching.

type Result added in v1.17.0

type Result struct {
	Config   *Config
	Warnings []string
}

func Load

func Load(path string) (*Result, error)

type Scheme

type Scheme uint
const (
	HTTP Scheme = iota
	HTTPS
)

func (Scheme) MarshalJSON

func (s Scheme) MarshalJSON() ([]byte, error)

func (Scheme) String

func (s Scheme) String() string

type ServerConfig

type ServerConfig struct {
	Host      string `json:"host,omitempty" mapstructure:"host"`
	Protocol  Scheme `json:"protocol,omitempty" mapstructure:"protocol"`
	HTTPPort  int    `json:"httpPort,omitempty" mapstructure:"http_port"`
	HTTPSPort int    `json:"httpsPort,omitempty" mapstructure:"https_port"`
	GRPCPort  int    `json:"grpcPort,omitempty" mapstructure:"grpc_port"`
	CertFile  string `json:"certFile,omitempty" mapstructure:"cert_file"`
	CertKey   string `json:"certKey,omitempty" mapstructure:"cert_key"`
}

ServerConfig contains fields, which configure both HTTP and gRPC API serving.

type StaticAuthenticationMethodInfo added in v1.17.0

type StaticAuthenticationMethodInfo struct {
	AuthenticationMethodInfo
	Enabled bool
	Cleanup *AuthenticationCleanupSchedule
}

StaticAuthenticationMethodInfo embeds an AuthenticationMethodInfo alongside the other properties of an AuthenticationMethod.

type TracingConfig

type TracingConfig struct {
	Jaeger JaegerTracingConfig `json:"jaeger,omitempty" mapstructure:"jaeger"`
}

TracingConfig contains fields, which configure tracing telemetry output destinations.

type UIConfig

type UIConfig struct {
	Enabled bool `json:"enabled" mapstructure:"enabled"`
}

UIConfig contains fields, which control the behaviour of Flipt's user interface.

Jump to

Keyboard shortcuts

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