cmd

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FocalCmd = &cobra.Command{
	Use:     "focal",
	Short:   "PAM authenticated proxy",
	Long:    "A PAM authenticated proxy that supports JWT authentication and header authentication downstream",
	Example: `focal --token <token> --directory /path/to/directory.yml`,
	Run: func(cmd *cobra.Command, args []string) {

		viper.SetEnvPrefix("focal")
		viper.AutomaticEnv()

		err := viper.Unmarshal(&configuration)

		config := GetConfig()

		if err != nil {
			log.Fatalf("Unable to marshall viper into the designated struct. Details are: %s", err)
		}

		ta = jwtauth.New("HS256", []byte(config.Token), nil)

		directory, err := buildDirectory(config)

		if err != nil {
			log.Fatalf("Unable to read the provided directory file: %s", err)
		}

		r := Routes(directory)

		log.Infof("Listening on port %d", config.Port)
		http.ListenAndServe(":"+strconv.Itoa(config.Port), r)
	},
}

FocalCmdf is the primary cobra command executed to launch the service

Functions

func Execute

func Execute() error

func Routes

func Routes(directory Directions) chi.Router

Types

type Config

type Config struct {
	Directory string `yaml:"directory" json:"directory,omitempty"`
	Token     string `yaml:"token" json:"token,omitempty"`
	RootURL   string `mapstructure:"root_url" yaml:"root" json:"root,omitempty"`
	Port      int    `yaml:"port" json:"port,omitempty"`
}

func GetConfig

func GetConfig() *Config

type Direction

type Direction struct {
	Name   string `yaml:"name"`
	Target string `yaml:"upstream"`
	Type   string `yaml:"type"`
}

Direction is a component used for dynamic routing

type Directions

type Directions []Direction

Directions is a listing of objects that should be used for building reverse proxy targets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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