config

package
v0.21.2 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: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTLSGenDir = os.ExpandEnv("$HOME/.config/topaz/certs")
	CertificateSets  = []string{"grpc", "gateway"}
)

Functions

func NewLoggerConfig

func NewLoggerConfig(configPath Path, overrides Overrider) (*logger.Config, error)

NewLoggerConfig creates a new LoggerConfig.

Types

type AuthnConfig

type AuthnConfig struct {
	APIKeys map[string]string `json:"api_keys"`
	Options CallOptions       `json:"options"`
}

type CallOptions

type CallOptions struct {
	Default   Options           `json:"default"`
	Overrides []OptionOverrides `json:"overrides"`
}

func (*CallOptions) ForPath

func (co *CallOptions) ForPath(path string) *Options

type CommandMode

type CommandMode int

CommandMode -- enum type.

const (
	CommandModeUnknown CommandMode = 0 + iota
	CommandModeRun
	CommandModeBuild
)

CommandMode -- enum constants.

type Common

type Common struct {
	Logging logger.Config `json:"logging"`

	Command struct {
		Mode CommandMode
	} `json:"-"`

	API struct {
		GRPC struct {
			ListenAddress string `json:"listen_address"`
			// Default connection timeout is 120 seconds
			// https://godoc.org/google.golang.org/grpc#ConnectionTimeout
			ConnectionTimeoutSeconds uint32               `json:"connection_timeout_seconds"`
			Certs                    certs.TLSCredsConfig `json:"certs"`
		} `json:"grpc"`
		Gateway struct {
			ListenAddress     string               `json:"listen_address"`
			AllowedOrigins    []string             `json:"allowed_origins"`
			Certs             certs.TLSCredsConfig `json:"certs"`
			HTTP              bool                 `json:"http"`
			ReadTimeout       time.Duration        `json:"read_timeout"`
			ReadHeaderTimeout time.Duration        `json:"read_header_timeout"`
			WriteTimeout      time.Duration        `json:"write_timeout"`
			IdleTimeout       time.Duration        `json:"idle_timeout"`
		} `json:"gateway"`
		Health struct {
			ListenAddress string `json:"listen_address"`
		} `json:"health"`
	} `json:"api"`

	JWT struct {
		// Specifies the duration in which exp (Expiry) and nbf (Not Before)
		// claims may differ by. This value should be positive.
		AcceptableTimeSkewSeconds int `json:"acceptable_time_skew_seconds"`
	} `json:"jwt"`

	// Directory configuration
	Directory directory.Config `json:"directory_service"`

	// Default OPA configuration
	OPA runtime.Config `json:"opa"`
}

Config holds the configuration for the app.

type Config

type Config struct {
	Common         `json:",squash"` // nolint:staticcheck // squash is used by mapstructure
	Auth           AuthnConfig      `json:"auth"`
	DecisionLogger file.Config      `json:"decision_logger"`
}

func NewConfig

func NewConfig(configPath Path, log *zerolog.Logger, overrides Overrider, certsGenerator *certs.Generator) (*Config, error)

NewConfig creates the configuration by reading env & files.

type LoggerConfig

type LoggerConfig Config

LoggerConfig is a basic Config copy that gets loaded before everything else, so we can log during resolving configuration.

type OptionOverrides

type OptionOverrides struct {
	// API paths to override
	Paths []string `json:"paths"`
	// Override options
	Override Options `json:"override"`
}

type Options

type Options struct {

	// API Key for machine-to-machine communication, internal to Aserto
	EnableAPIKey bool `json:"enable_api_key"`
	// Allows calls without any form of authentication
	EnableAnonymous bool `json:"enable_anonymous"`
}

type Overrider

type Overrider func(*Config)

Overrider is a func that mutates configuration.

type Path

type Path string

Path represents the path to a configuration file.

Jump to

Keyboard shortcuts

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