Ver código fonte

Check authorization before semaphore

DarthSim 7 anos atrás
pai
commit
ec627e3345
1 arquivos alterados com 4 adições e 4 exclusões
  1. 4 4
      server.go

+ 4 - 4
server.go

@@ -169,15 +169,15 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
 		}
 	}()
 
+	if !checkSecret(r.Header.Get("Authorization")) {
+		panic(invalidSecretErr)
+	}
+
 	t := startTimer(time.Duration(conf.WriteTimeout) * time.Second)
 
 	h.lock()
 	defer h.unlock()
 
-	if !checkSecret(r.Header.Get("Authorization")) {
-		panic(invalidSecretErr)
-	}
-
 	if r.URL.Path == "/health" {
 		rw.WriteHeader(200)
 		rw.Write([]byte("imgproxy is running"))