Skip to content

Commit

Permalink
Basic auth (#26)
Browse files Browse the repository at this point in the history
* make basic auth the default

* update root command help
  • Loading branch information
pr8kerl committed Nov 22, 2017
1 parent 49b88a1 commit 44e03ec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ If you are a prometheus user, then also check out [bigip_exporter](https://githu

## Installation

Use docker and docker-compose to build.
You can download the latest build for Mac, Linux or Windows from the [releases](https://github.com/pr8kerl/f5er/releases) page.

### Build

Use docker and docker-compose to build it yourself.

```
docker-compose run make [linux|windows|darwin]
Expand All @@ -33,6 +37,7 @@ make
## Configuration

**f5er** looks for configuration in the current environment, or if not found in a config file.
You must provide config for the device (ip address or hostname), as well as username and password.

### Environment variables

Expand All @@ -57,7 +62,7 @@ Below is a full example of all current configurables.
"device": "192.168.0.100",
"username": "admin",
"passwd": "superSecretSquirrel",
"token": true,
"token": false,
"stats_path_prefix": "prd.f5.bigip01",
"stats_show_zero_values": false
}
Expand All @@ -72,11 +77,11 @@ The **stats_** configuration options (used for displaying statistics) are only a
### Authentication

Big-IP devices allow authentication to the REST API using basic http authentication or using a proprietary token authentication. The default is to use
the token auth method. To use only basic auth, you can set the token flag to false on the command line, in the config file, or using the F5_TOKEN environment variable.
basic auth method. To use token auth, you can set the token flag to true on the command line, in the config file, or using the F5_TOKEN environment variable.

```
f5er --token=false show pool
F5_TOKEN=fale f5er show pool
f5er --token=true show pool
F5_TOKEN=true f5er show pool
```

## Usage
Expand Down
5 changes: 5 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"

"github.com/pr8kerl/f5er/f5"
Expand All @@ -16,6 +17,10 @@ var f5Cmd = &cobra.Command{
Short: "tickle an F5 load balancer using REST",
Long: "A utility to manage F5 configuration objects",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
cmd.Help()
os.Exit(1)
}
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
checkFlags(cmd)
Expand Down
1 change: 0 additions & 1 deletion f5/f5.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (f *Device) SetTokenAuth(t bool) {
}
if debug {
fmt.Printf("authentication mode: %s\n", debugout)

}
}

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func initialiseConfig() {
viper.AddConfigPath(".")
viper.SetDefault("username", "admin")
viper.SetDefault("debug", false)
viper.SetDefault("token", true)
viper.SetDefault("token", false)
viper.SetDefault("force", false)
viper.SetDefault("statsPathPrefix", "f5")
viper.SetDefault("statsShowZeroValues", false)
Expand Down Expand Up @@ -91,7 +91,7 @@ func checkFlags(cmd *cobra.Command) {

// this has to be done here inside cobraCommand.Execute() inc case cmd line args are passed.
// args are only parsed after cobraCommand.Run() - urgh
appliance = f5.New(f5Host, username, passwd, f5.TOKEN)
appliance = f5.New(f5Host, username, passwd, f5.BASIC_AUTH)
appliance.SetDebug(debug)
appliance.SetTokenAuth(token)
appliance.SetStatsPathPrefix(statsPathPrefix)
Expand All @@ -110,7 +110,7 @@ func init() {

f5Cmd.PersistentFlags().StringVarP(&f5Host, "f5", "f", "", "IP or hostname of F5 to poke")
f5Cmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "debug output")
f5Cmd.PersistentFlags().BoolVarP(&token, "token", "t", true, "use token auth")
f5Cmd.PersistentFlags().BoolVarP(&token, "token", "t", false, "use token auth")
f5Cmd.PersistentFlags().StringVarP(&f5Input, "input", "i", "", "input json f5 configuration")
offlinePoolMemberCmd.Flags().StringVarP(&f5Pool, "pool", "p", "", "F5 pool name")
offlinePoolMemberCmd.Flags().BoolVarP(&now, "now", "n", false, "force member offline immediately")
Expand Down

0 comments on commit 44e03ec

Please sign in to comment.