1
0
Fork 0
mirror of https://github.com/shouptech/tempgopher.git synced 2026-02-03 16:49:42 +00:00

Add script and docs for auth

This commit is contained in:
Emma 2018-10-13 19:23:49 -06:00
parent ffe11c1965
commit 64ca5a3bfd
2 changed files with 33 additions and 0 deletions

View file

@ -40,6 +40,7 @@ You will be asked some questions during the initial configuration of TempGopher.
* `Invert heating switch` - If set to `true`, the heating will be ON when the switch is LOW. This should usually be `false`, so that is the default * `Invert heating switch` - If set to `true`, the heating will be ON when the switch is LOW. This should usually be `false`, so that is the default
* `Enable verbose logging` - If set to `true`, TempGopher will display in the console every thermostat reading. This can be quite verbose, so the default is `false`. * `Enable verbose logging` - If set to `true`, TempGopher will display in the console every thermostat reading. This can be quite verbose, so the default is `false`.
* `Write data to an Influx database?` - Whether or not to configure an Influx database * `Write data to an Influx database?` - Whether or not to configure an Influx database
* `Enable user authentication?` - Whether or not to enable authentication
## Example configuration script ## Example configuration script
@ -83,4 +84,11 @@ Influx UserAgent [InfluxDBClient]:
Influx timeout (in seconds) [30]: Influx timeout (in seconds) [30]:
Influx database []: tempgopher Influx database []: tempgopher
Enable InsecureSkipVerify? [fasle]: Enable InsecureSkipVerify? [fasle]:
Username: mike
Password: ********
Add another user? [y/N]: y
Username: foo
Password: ***
Add another user? [y/N]: n
``` ```

25
cli.go
View file

@ -7,6 +7,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/howeyc/gopass"
"github.com/yryz/ds18b20" "github.com/yryz/ds18b20"
) )
@ -190,6 +192,29 @@ func PromptForConfiguration() Config {
} }
} }
fmt.Println("Enable user authentication?")
fmt.Print("[Y/n]: ")
choice = ReadInput(reader, "y")
if strings.ToLower(choice)[0] == 'y' {
another := true
for another {
fmt.Print("Username: ")
username := ReadInput(reader, "")
fmt.Print("Password: ")
password, err := gopass.GetPasswdMasked()
if err != nil {
panic(err)
}
config.Users = append(config.Users, User{username, string(password)})
fmt.Print("Add another user? [y/N]: ")
choice = ReadInput(reader, "n")
if strings.ToLower(choice)[0] == 'n' {
another = false
}
}
}
return config return config
} }