Skip to content
Snippets Groups Projects
Commit a9c941a3 authored by ale's avatar ale
Browse files

Renamed Configuration to Config for uniformity

parent bd34d614
No related branches found
No related tags found
No related merge requests found
......@@ -22,13 +22,13 @@ var (
configFile = flag.String("config", "/etc/sso/proxy.yml", "path of config file")
)
func loadConfig() (*proxy.Configuration, error) {
func loadConfig() (*proxy.Config, error) {
// Read YAML config.
data, err := ioutil.ReadFile(*configFile)
if err != nil {
return nil, err
}
var config proxy.Configuration
var config proxy.Config
if err := yaml.Unmarshal(data, &config); err != nil {
return nil, err
}
......
......@@ -52,39 +52,10 @@ func (b *Backend) newHandler(ssow *httpsso.SSOWrapper) (http.Handler, error) {
return h, nil
}
// func buildServerTLSConfig(config *Configuration) (*tls.Config, error) {
// var certs []tls.Certificate
// for _, b := range config.Backends {
// cert, err := tls.LoadX509KeyPair(b.ServerTLSConfig.Cert, b.ServerTLSConfig.Key)
// if err != nil {
// return nil, err
// }
// certs = append(certs, cert)
// }
// c := &tls.Config{
// Certificates: certs,
// }
// if config.CA != "" {
// cas, err := loadCA(config.CA)
// if err != nil {
// return nil, err
// }
// c.ClientAuth = tls.RequireAndVerifyClientCert
// c.ClientCAs = cas
// }
// c.BuildNameToCertificate()
// return c, nil
// }
// Configuration for the proxy.
type Configuration struct {
// Config for the proxy.
type Config struct {
SessionAuthKey string `yaml:"session_auth_key"`
SessionEncKey string `yaml:"session_enc_key"`
//CA string `yaml:"ca"`
SSOLoginServerURL string `yaml:"sso_server_url"`
SSOPublicKeyFile string `yaml:"sso_public_key_file"`
......@@ -94,7 +65,7 @@ type Configuration struct {
}
// Sanity checks for the configuration.
func (c *Configuration) check() error {
func (c *Config) check() error {
switch len(c.SessionAuthKey) {
case 32, 64:
case 0:
......@@ -120,7 +91,7 @@ func (c *Configuration) check() error {
// NewProxy builds a SSO-protected multi-host handler with the
// specified configuration.
func NewProxy(config *Configuration) (http.Handler, error) {
func NewProxy(config *Config) (http.Handler, error) {
if err := config.check(); err != nil {
return nil, err
}
......@@ -130,7 +101,13 @@ func NewProxy(config *Configuration) (http.Handler, error) {
return nil, err
}
w, err := httpsso.NewSSOWrapper(config.SSOLoginServerURL, pkey, config.SSODomain, []byte(config.SessionAuthKey), []byte(config.SessionEncKey))
w, err := httpsso.NewSSOWrapper(
config.SSOLoginServerURL,
pkey,
config.SSODomain,
[]byte(config.SessionAuthKey),
[]byte(config.SessionEncKey),
)
if err != nil {
return nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment