Skip to content
Snippets Groups Projects
Unverified Commit 950d0011 authored by Max Adamo's avatar Max Adamo
Browse files

fix token

parent 9df32105
No related branches found
No related tags found
No related merge requests found
...@@ -82,8 +82,8 @@ func triggerPuppet(w http.ResponseWriter, req *http.Request) { ...@@ -82,8 +82,8 @@ func triggerPuppet(w http.ResponseWriter, req *http.Request) {
cmd := exec.Command("/usr/bin/touch", "/TEST") cmd := exec.Command("/usr/bin/touch", "/TEST")
authToken := strings.Split(req.Header.Get("Authorization"), "Bearer ")[1] authToken := strings.Split(req.Header.Get("Authorization"), "Bearer ")[1]
statusFile := "/tmp/200.json" 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\": \"OK\",\n \"response\": 200\n \"token\": %v\n}", 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\": \"KO\",\n \"response\": 503\n \"token\": %v\n}", authToken), "/tmp/503.json")
if authToken != bearerToken { if authToken != bearerToken {
statusFile = "/tmp/503.json" statusFile = "/tmp/503.json"
//w.WriteHeader(http.StatusUnauthorized) //w.WriteHeader(http.StatusUnauthorized)
...@@ -138,7 +138,8 @@ Options: ...@@ -138,7 +138,8 @@ Options:
fmt.Printf("Fail to read file: %v", err) fmt.Printf("Fail to read file: %v", err)
os.Exit(1) 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" webDir = "/var/www/acme_web"
jsonConverter = arguments["--json-converter"].(string) jsonConverter = arguments["--json-converter"].(string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment