From f5b1fb3d0ef37ed44b8f7302343dcd5cd16bd725 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 21:36:20 +0200 Subject: Make the `password_cmd` config setting work Given a string from `password_cmd`, we should execute it as a shell command and assume the result is a password. That password then gets submitted to TimeTask's login form for authentication. Had to do a bit of wrangling to get the command to execute by `exec.Command()`, but managed to get it working in a bit of a roundabout way. Found these resources in my searches: - https://stackoverflow.com/questions/39930109/golang-execute-command#39930127 https://stackoverflow.com/questions/28783637/how-to-make-golang-execute-a-string - https://stackoverflow.com/questions/20437336/how-to-execute-system-command-in-golang-with-unknown-arguments - https://github.com/codeskyblue/go-sh --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index ae18a87..ab0fc4a 100644 --- a/main.go +++ b/main.go @@ -87,9 +87,12 @@ func main() { *description, ) + password, err := passwordCmd(config.Auth.PasswordCmd) + kingpin.FatalIfError(err, "password command failed") + resp, client, err := timetask.Login( config.Auth.Username, - config.Auth.PasswordCmd, + password, ) kingpin.FatalIfError(err, "Login request failed") log.Printf("%+v\n", resp) -- cgit v1.2.3