Example #1
0
File: tuf.go Project: cyli/notary
func getTrustPinning(config *viper.Viper) (trustpinning.TrustPinConfig, error) {
	var ok bool
	// Need to parse out Certs section from config
	certMap := config.GetStringMap("trust_pinning.certs")
	resultCertMap := make(map[string][]string)
	for gun, certSlice := range certMap {
		var castedCertSlice []interface{}
		if castedCertSlice, ok = certSlice.([]interface{}); !ok {
			return trustpinning.TrustPinConfig{}, fmt.Errorf("invalid format for trust_pinning.certs")
		}
		certsForGun := make([]string, len(castedCertSlice))
		for idx, certIDInterface := range castedCertSlice {
			if certID, ok := certIDInterface.(string); ok {
				certsForGun[idx] = certID
			} else {
				return trustpinning.TrustPinConfig{}, fmt.Errorf("invalid format for trust_pinning.certs")
			}
		}
		resultCertMap[gun] = certsForGun
	}
	return trustpinning.TrustPinConfig{
		DisableTOFU: config.GetBool("trust_pinning.disable_tofu"),
		CA:          config.GetStringMapString("trust_pinning.ca"),
		Certs:       resultCertMap,
	}, nil
}
Example #2
0
func loadEndpointsConfig(v *viper.Viper) {
	//Login
	Config.LoginURI = v.GetString("stormpath.web.login.uri")
	Config.LoginNextURI = v.GetString("stormpath.web.login.nextUri")
	Config.LoginView = v.GetString("stormpath.web.login.view")
	Config.LoginEnabled = v.GetBool("stormpath.web.login.enabled")
	Config.LoginForm = buildForm("login", v)
	//Register
	Config.RegisterURI = v.GetString("stormpath.web.register.uri")
	Config.RegisterView = v.GetString("stormpath.web.register.view")
	Config.RegisterNextURI = v.GetString("stormpath.web.register.uri")
	Config.RegisterEnabled = v.GetBool("stormpath.web.register.enabled")
	Config.RegisterAutoLoginEnabled = v.GetBool("stormpath.web.register.autoLogin")
	Config.RegisterForm = buildForm("register", v)
	//Verify
	Config.VerifyURI = v.GetString("stormpath.web.verifyEmail.uri")
	Config.VerifyEnabled = loadBoolPtr("stormpath.web.verifyEmail.enabled", v)
	Config.VerifyView = v.GetString("stormpath.web.verifyEmail.view")
	Config.VerifyNextURI = v.GetString("stormpath.web.verifyEmail.nextUri")
	//Forgot Password
	Config.ForgotPasswordURI = v.GetString("stormpath.web.forgotPassword.uri")
	Config.ForgotPasswordNextURI = v.GetString("stormpath.web.forgotPassword.nextUri")
	Config.ForgotPasswordView = v.GetString("stormpath.web.forgotPassword.view")
	Config.ForgotPasswordEnabled = loadBoolPtr("stormpath.web.forgotPassword.enabled", v)
	//Change Password
	Config.ChangePasswordURI = v.GetString("stormpath.web.changePassword.uri")
	Config.ChangePasswordNextURI = v.GetString("stormpath.web.changePassword.nextUri")
	Config.ChangePasswordView = v.GetString("stormpath.web.changePassword.view")
	Config.ChangePasswordEnabled = loadBoolPtr("stormpath.web.changePassword.enabled", v)
	Config.ChangePasswordAutoLoginEnabled = v.GetBool("stormpath.web.changePassword.autoLogin")
	Config.ChangePasswordErrorURI = v.GetString("stormpath.web.changePassword.errorUri")
	//Logout
	Config.LogoutURI = v.GetString("stormpath.web.logout.uri")
	Config.LogoutNextURI = v.GetString("stormpath.web.logout.nextUri")
	Config.LogoutEnabled = v.GetBool("stormpath.web.logout.enabled")
	//IDSite
	Config.IDSiteEnabled = v.GetBool("stormpath.web.idSite.enabled")
	Config.IDSiteLoginURI = v.GetString("stormpath.web.idSite.loginUri")
	Config.IDSiteForgotURI = v.GetString("stormpath.web.idSite.forgotUri")
	Config.IDSiteRegisterURI = v.GetString("stormpath.web.idSite.registerUri")
	Config.CallbackEnabled = v.GetBool("stormpath.web.callback.enabled")
	Config.CallbackURI = v.GetString("stormpath.web.callback.uri")
	//Me
	Config.MeEnabled = v.GetBool("stormpath.web.me.enabled")
	Config.MeURI = v.GetString("stormpath.web.me.uri")
	Config.MeExpand = v.GetStringMap("stormpath.web.me.expand")
}
Example #3
0
func zoneproxy(v *viper.Viper, dp *dialer.DialerPool) {
	var wg sync.WaitGroup

	zones := v.GetStringMap("zones")
	dp.AddByZones(zones)

	tcpproxys := v.GetStringMap("tcpproxys")
	for name, _ := range tcpproxys {
		address := v.GetString("tcpproxys." + name + ".address")
		if address == "" {
			glog.Fatalln("tcpproxys." + name + ".address must be string")
		}
		tp := tcpproxy.NewTcpProxy(name, address, dp, v)
		wg.Add(1)
		go func() {
			tp.Run()
			wg.Done()
		}()
	}

	httpproxys := v.GetStringMap("httpproxys")
	for name, _ := range httpproxys {
		address := v.GetString("httpproxys." + name + ".address")
		if address == "" {
			glog.Fatalln("httpproxys." + name + ".address must be string")
		}
		hp := httpproxy.NewHttpProxy(name, address, dp, v)
		wg.Add(1)
		go func() {
			hp.Run()
			wg.Done()
		}()
	}

	httpservers := v.GetStringMap("httpservers")
	for name, _ := range httpservers {
		address := v.GetString("httpservers." + name + ".address")
		if address == "" {
			glog.Fatalln("httpservers." + name + ".address must be string")
		}
		hs := httpserver.NewHttpServer(name, address, dp, v)
		wg.Add(1)
		go func() {
			hs.Run()
			wg.Done()
		}()
	}

	wg.Wait()
	glog.Flush()
}
Example #4
0
func singalhandler(sig os.Signal, v *viper.Viper, dp *dialer.DialerPool) error {
	switch sig {
	case syscall.SIGHUP:
		log.Println("HUP")
		glog.Infof("got hup signal, now reloading conf\n", sig.String())
		err := v.ReadInConfig()
		if err != nil {
			glog.Infoln("Fatal error config file ", err)
			return utils.ErrReadConfig
		}
		zones := v.GetStringMap("zones")
		dp.AddByZones(zones)
	case syscall.SIGTERM:
		glog.Infoln("receive SIGTERM, exit")
		//maybe graceful stop is better:)
		os.Exit(0)
	default:
		log.Println(sig)
		glog.Infoln("not ready to process ", sig.String())
	}

	return nil
}