package config

import "github.com/spf13/viper"

type Config struct {
	Viper          *viper.Viper
	DataMaps       DataMaps
	ReverseProxies ReverseProxies           `mapstructure:"reverse_proxies"`
	TLS            TLS                      `mapstructure:"tls"`
	EntryPoints    EntryPoints              `mapstructure:"entry_points"`
	Auth           map[string]*AuthInstance `mapstructure:"auth"`
}

type DataMaps struct {
	DomainToProxy map[string]string
	DomainToAuth  map[string]string
	DomainToCert  map[string]string
}

// AUTH
// type Auth map[string]AuthInstance

type AuthInstance struct {
	Paths  Paths  `mapstructure:"paths"`
	OpenID OpenID `mapstructure:"open_id"`
}
type Paths struct {
	Prefix   string `mapstructure:"prefix"`
	Login    string `mapstructure:"login"`
	Logout   string `mapstructure:"logout"`
	Callback string `mapstructure:"callback"`
}
type OpenID struct {
	Host                  string `mapstructure:"host"`
	Realm                 string `mapstructure:"realm"`
	ClientID              string `mapstructure:"client_id"`
	ClientSecert          string `mapstructure:"client_secret"`
	RedirectURI           string `mapstructure:"redirect_uri"`
	PostLogoutRedirectURI string `mapstructure:"post_logout_redirect_uri"`
	ConfigPath            string `mapstructure:"config_path"`
	EndPoints             *EndPoints
}

type EndPoints struct {
	Issuer        string
	Auth          string
	Introspection string
	Token         string
	UserInfo      string
	Logout        string
	JwksUri       string
}

// type OpenIdEndPoints struct {
// 	Issuer        string
// 	Authorization string
// 	Token         string
// 	Introspection string
// 	UserInfo      string
// 	EndSession    string
// }

// ReverseProxies

type ReverseProxies map[string]ReverseProxy

type ReverseProxy struct {
	Domain     string `mapstructure:"domain"`
	Host       string `mapstructure:"host"`
	EntryPoint string `mapstructure:"entry_point"`
	TLS        TLS_RP `mapstructure:"tls"`
	Auth       string `mapstructure:"auth"`
}
type TLS_RP struct {
	Enabled bool   `mapstructure:"enabled"`
	Certs   string `mapstructure:"certs"`
}

// TLS
type TLS struct {
	Certs map[string]Certs `mapstructure:"certs"`
}
type Certs struct {
	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
}

// EntryPoints
type EntryPoints map[string]EntryPoint
type EntryPoint struct {
	Port string `mapstructure:"port"`
	TLS  bool   `mapstructure:"tls"`
}
