From aa30a6e8f2d8e33757d10f9334b804831cf35899 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Thu, 6 Jul 2017 16:24:00 +1000 Subject: [PATCH] added intraApiConfig --- main.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 7d0f174..56f4bd1 100644 --- a/main.go +++ b/main.go @@ -35,6 +35,12 @@ func main() { log.Fatal("unable to read crm_config.json, program quit") } + err = IntraAPIConfig.readConfig() + if err != nil { + log.Println(err) + log.Fatal("unable to read intra-api-config, program quit") + } + initAllProc() setupRootFileServer() startSessionManager(2048) @@ -98,24 +104,11 @@ func dumpReuestHandler(w http.ResponseWriter, r *http.Request) { func supplyAccessToken(w http.ResponseWriter, r *http.Request) { logRequestDebug(httputil.DumpRequest(r, true)) - signature := "" - nonce := "" - timestamp := "" - for _, c := range r.Cookies() { - switch c.Name { - case "signature": - signature = c.Value - case "nonce": - nonce = c.Value - case "timestamp": - timestamp = c.Value - } - } - if verifySignature(signature, timestamp, nonce, IntraAPIConfig.CRMSecrete) { + if checkSignatureByToken(r, IntraAPIConfig.CRMSecrete) { atk, _ := GetAccessToken() fmt.Fprint(w, atk) } else { - fmt.Fprint(w, "fuck this world") + fmt.Fprint(w, "errortoken") } }