From 3ab055008c6437d30c78bce7a83306a7ce548f53 Mon Sep 17 00:00:00 2001 From: mountain Date: Tue, 13 Aug 2024 17:30:33 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=9D=BC=EB=8B=A8=20?= =?UTF-8?q?=EB=A7=89=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/http_handler.go | 55 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/server/http_handler.go b/server/http_handler.go index 43eb64f..124b109 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -3,7 +3,6 @@ package server import ( "crypto/md5" "encoding/hex" - "encoding/json" "fmt" "io" "net/http" @@ -173,37 +172,37 @@ func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Body.Close() }() - var userinfo map[string]any - if !*noauth && (*authtype == "on" || *authtype == "both") { - authheader := r.Header.Get("Authorization") - if len(authheader) == 0 { - logger.Println("Authorization header is not valid :", authheader) - w.WriteHeader(http.StatusBadRequest) - return - } + // var userinfo map[string]any + // if !*noauth && (*authtype == "on" || *authtype == "both") { + // authheader := r.Header.Get("Authorization") + // if len(authheader) == 0 { + // logger.Println("Authorization header is not valid :", authheader) + // w.WriteHeader(http.StatusBadRequest) + // return + // } - req, _ := http.NewRequest("GET", "https://graph.microsoft.com/oidc/userinfo", nil) - req.Header.Add("Authorization", authheader) - client := &http.Client{} + // req, _ := http.NewRequest("GET", "https://graph.microsoft.com/oidc/userinfo", nil) + // req.Header.Add("Authorization", authheader) + // client := &http.Client{} - resp, err := client.Do(req) - if err != nil { - logger.Println("graph microsoft api call failed :", err) - w.WriteHeader(http.StatusBadRequest) - return - } - defer resp.Body.Close() + // resp, err := client.Do(req) + // if err != nil { + // logger.Println("graph microsoft api call failed :", err) + // w.WriteHeader(http.StatusBadRequest) + // return + // } + // defer resp.Body.Close() - raw, _ := io.ReadAll(resp.Body) - if err = json.Unmarshal(raw, &userinfo); err != nil { - return - } + // raw, _ := io.ReadAll(resp.Body) + // if err = json.Unmarshal(raw, &userinfo); err != nil { + // return + // } - if _, expired := userinfo["error"]; expired { - w.WriteHeader(http.StatusUnauthorized) - return - } - } + // if _, expired := userinfo["error"]; expired { + // w.WriteHeader(http.StatusUnauthorized) + // return + // } + // } var operation string if r.Method == "POST" {