config

package
v1.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Plugin = iota
	ManagementClient
)

Variables

View Source
var Defaults = Config{
	Log: Log{
		Format: "console",
		Level:  "info",
	},
	HTTP: HTTP{
		BaseURL: &url.URL{
			Scheme: "http",
			Host:   "localhost:9000",
		},
		Listen: ":9000",
		TLS:    false,
		Check: HTTPCheck{
			IPAddr: false,
		},
	},
	OpenVpn: OpenVpn{
		Addr: &url.URL{
			Scheme:   "unix",
			Path:     "/run/openvpn/server.sock",
			OmitHost: true,
		},
		AuthTokenUser: true,
		Bypass: OpenVpnBypass{
			CommonNames: make([]string, 0),
		},
	},
	OAuth2: OAuth2{
		Provider: "generic",
		Issuer:   &url.URL{Scheme: "", Host: ""},
		Endpoints: OAuth2Endpoints{
			Auth:      &url.URL{Scheme: "", Host: ""},
			Discovery: &url.URL{Scheme: "", Host: ""},
			Token:     &url.URL{Scheme: "", Host: ""},
		},
		Client: OAuth2Client{},
		Validate: OAuth2Validate{
			Groups: make([]string, 0),
			Roles:  make([]string, 0),
			IPAddr: false,
			Issuer: true,
		},
		Scopes: []string{"openid", "profile"},
	},
}
View Source
var ErrRequired = errors.New("required")

Functions

func FlagSet added in v1.0.0

func FlagSet() *flag.FlagSet

FlagSet configure the command line parser using flag library.

func StringToTemplateHookFunc added in v1.6.0

func StringToTemplateHookFunc() mapstructure.DecodeHookFuncType

StringToTemplateHookFunc parse a string to template.Template.

func StringToURLHookFunc added in v1.7.0

func StringToURLHookFunc() mapstructure.DecodeHookFuncType

StringToURLHookFunc parse a string to url.URL.

func Validate added in v1.0.0

func Validate(mode int, conf Config) error

Validate validates the config.

Types

type Config

type Config struct {
	ConfigFile string  `koanf:"config"`
	Log        Log     `koanf:"log"`
	HTTP       HTTP    `koanf:"http"`
	OpenVpn    OpenVpn `koanf:"openvpn"`
	OAuth2     OAuth2  `koanf:"oauth2"`
}

func Load added in v1.8.0

func Load(mode int, configFile string, flagSet *flag.FlagSet) (Config, error)

type HTTP added in v1.7.0

type HTTP struct {
	Listen             string             `koanf:"listen"`
	CertFile           string             `koanf:"cert"`
	KeyFile            string             `koanf:"key"`
	TLS                bool               `koanf:"tls"`
	BaseURL            *url.URL           `koanf:"baseurl"`
	Secret             string             `koanf:"secret"`
	CallbackTemplate   *template.Template `koanf:"callback-template-path"`
	Check              HTTPCheck          `koanf:"check"`
	EnableProxyHeaders bool               `koanf:"enable-proxy-headers"`
}

type HTTPCheck added in v1.7.0

type HTTPCheck struct {
	IPAddr bool `koanf:"ipaddr"`
}

type Log added in v1.0.0

type Log struct {
	Format string `koanf:"format"`
	Level  string `koanf:"level"`
}

type OAuth2 added in v1.0.0

type OAuth2 struct {
	Issuer          *url.URL        `koanf:"issuer"`
	Provider        string          `koanf:"provider"`
	AuthorizeParams string          `koanf:"authorize-params"`
	Endpoints       OAuth2Endpoints `koanf:"endpoint"`
	Client          OAuth2Client    `koanf:"client"`
	Scopes          []string        `koanf:"scopes"`
	Pkce            bool            `koanf:"pkce"`
	Validate        OAuth2Validate  `koanf:"validate"`
}

type OAuth2Client added in v1.0.0

type OAuth2Client struct {
	ID     string `koanf:"id"`
	Secret string `koanf:"secret"`
}

type OAuth2Endpoints added in v1.2.0

type OAuth2Endpoints struct {
	Discovery *url.URL `koanf:"discovery"`
	Auth      *url.URL `koanf:"auth"`
	Token     *url.URL `koanf:"token"`
}

type OAuth2Validate added in v1.0.0

type OAuth2Validate struct {
	Groups     []string `koanf:"groups"`
	Roles      []string `koanf:"roles"`
	IPAddr     bool     `koanf:"ipaddr"`
	Issuer     bool     `koanf:"issuer"`
	CommonName string   `koanf:"common_name"`
}

type OpenVpn added in v1.0.0

type OpenVpn struct {
	Addr          *url.URL      `koanf:"addr"`
	Password      string        `koanf:"password"`
	Bypass        OpenVpnBypass `koanf:"bypass"`
	AuthTokenUser bool          `koanf:"auth-token-user"`
}

type OpenVpnBypass added in v1.1.0

type OpenVpnBypass struct {
	CommonNames []string `koanf:"cn"`
}

Jump to

Keyboard shortcuts

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