noauth대신 authtype 파라미터 사용

This commit is contained in:
2024-07-10 14:55:47 +09:00
parent fb3886e2e4
commit 401cfa8b84

View File

@ -153,6 +153,7 @@ func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string
} }
var noauth = flagx.Bool("noauth", false, "") var noauth = flagx.Bool("noauth", false, "")
var authtype = flagx.String("auth", "on", "on|off|both")
func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
@ -169,7 +170,7 @@ func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}() }()
var userinfo map[string]any var userinfo map[string]any
if !*noauth { if !*noauth && (*authtype == "on" || *authtype == "both") {
authheader := r.Header.Get("Authorization") authheader := r.Header.Get("Authorization")
if len(authheader) == 0 { if len(authheader) == 0 {
logger.Println("Authorization header is not valid :", authheader) logger.Println("Authorization header is not valid :", authheader)