app

package
v0.0.0-...-48a65c6 Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "minimal-ldap-proxy",
	Short: "Proxy ldap authentication requests to a database backend",
	Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,

	PreRunE: func(cmd *cobra.Command, args []string) error {
		jww.SetStdoutThreshold(jww.LevelInfo)

		err := loadConfig()
		if err != nil {
			return err
		}

		if !util.ContainsString(sql.Drivers(), cmdConfig.Driver) {
			return fmt.Errorf("%s is not one of the supported drivers: %s", cmdConfig.Driver, strings.Join(sql.Drivers(), ", "))
		}

		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		backend, err := pkg.NewBackend(cmdConfig.Driver, cmdConfig.Conn, cmdConfig.AuthQuery, cmdConfig.SearchQuery)
		if err != nil {
			jww.ERROR.Fatalf("Error configuring backend: %v", err)
		}

		cert, err := tls.LoadX509KeyPair(cmdConfig.Cert, cmdConfig.Key)
		if err != nil {
			jww.ERROR.Fatalf("Error loading tls certificate: %v", err)
		}

		frontend := pkg.NewFrontend(cmdConfig.ServerAddress, cert, cmdConfig.BaseDn, cmdConfig.Rdn, cmdConfig.Attributes, backend)

		frontend.Serve()

		ch := make(chan os.Signal)
		signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
		<-ch
		close(ch)

		frontend.Stop()
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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