From 950d001106a23b8bde7ee60c8c1f02c6b86cefed Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <maxadamo@gmail.com> Date: Thu, 1 Sep 2022 00:01:35 +0200 Subject: [PATCH] fix token --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4a56fa9..5b84317 100644 --- a/main.go +++ b/main.go @@ -82,8 +82,8 @@ func triggerPuppet(w http.ResponseWriter, req *http.Request) { cmd := exec.Command("/usr/bin/touch", "/TEST") authToken := strings.Split(req.Header.Get("Authorization"), "Bearer ")[1] statusFile := "/tmp/200.json" - writeFile(fmt.Sprintf("{\n \"status\": \"OK\",\n \"response\": 200\n \"token\": %v}", authToken), "/tmp/200.json") - writeFile(fmt.Sprintf("{\n \"status\": \"KO\",\n \"response\": 503\n \"token\": %v}", authToken), "/tmp/503.json") + writeFile(fmt.Sprintf("{\n \"status\": \"OK\",\n \"response\": 200\n \"token\": %v\n}", authToken), "/tmp/200.json") + writeFile(fmt.Sprintf("{\n \"status\": \"KO\",\n \"response\": 503\n \"token\": %v\n}", authToken), "/tmp/503.json") if authToken != bearerToken { statusFile = "/tmp/503.json" //w.WriteHeader(http.StatusUnauthorized) @@ -138,7 +138,8 @@ Options: fmt.Printf("Fail to read file: %v", err) os.Exit(1) } - bearerToken = fmt.Sprintf("Bearer %v", cfg.Section("acme").Key("bearer_token").String()) + //bearerToken = fmt.Sprintf("Bearer %v", cfg.Section("acme").Key("bearer_token").String()) + bearerToken = cfg.Section("acme").Key("bearer_token").String() webDir = "/var/www/acme_web" jsonConverter = arguments["--json-converter"].(string) -- GitLab