인증 일단 막음

This commit is contained in:
2024-08-13 17:30:33 +09:00
parent 71e80d2908
commit 3ab055008c

View File

@ -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" {