mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 08:39:43 +00:00
Add script and docs for auth
This commit is contained in:
parent
ffe11c1965
commit
64ca5a3bfd
2 changed files with 33 additions and 0 deletions
|
|
@ -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
|
||||
* `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
|
||||
* `Enable user authentication?` - Whether or not to enable authentication
|
||||
|
||||
## Example configuration script
|
||||
|
||||
|
|
@ -83,4 +84,11 @@ Influx UserAgent [InfluxDBClient]:
|
|||
Influx timeout (in seconds) [30]:
|
||||
Influx database []: tempgopher
|
||||
Enable InsecureSkipVerify? [fasle]:
|
||||
Username: mike
|
||||
Password: ********
|
||||
Add another user? [y/N]: y
|
||||
Username: foo
|
||||
Password: ***
|
||||
Add another user? [y/N]: n
|
||||
|
||||
```
|
||||
|
|
|
|||
25
cli.go
25
cli.go
|
|
@ -7,6 +7,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/howeyc/gopass"
|
||||
|
||||
"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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue