| log.Fatal("unable to read crm_config.json, program quit") | 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() | initAllProc() | ||||
| setupRootFileServer() | setupRootFileServer() | ||||
| startSessionManager(2048) | startSessionManager(2048) | ||||
| func supplyAccessToken(w http.ResponseWriter, r *http.Request) { | func supplyAccessToken(w http.ResponseWriter, r *http.Request) { | ||||
| logRequestDebug(httputil.DumpRequest(r, true)) | 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() | atk, _ := GetAccessToken() | ||||
| fmt.Fprint(w, atk) | fmt.Fprint(w, atk) | ||||
| } else { | } else { | ||||
| fmt.Fprint(w, "fuck this world") | |||||
| fmt.Fprint(w, "errortoken") | |||||
| } | } | ||||
| } | } |