Validate incoming requests (#7234)

master
Krishna Srinivas 6 years ago committed by Harshavardhana
parent 118270d76f
commit 14544d8d84
  1. 2
      cmd/storage-rest-common.go
  2. 10
      cmd/storage-rest-server.go

@ -16,7 +16,7 @@
package cmd
const storageRESTVersion = "v3"
const storageRESTVersion = "v4"
const storageRESTPath = minioReservedBucketPath + "/storage/" + storageRESTVersion + "/"
const (

@ -43,8 +43,18 @@ func (s *storageRESTServer) writeErrorResponse(w http.ResponseWriter, err error)
w.Write([]byte(err.Error()))
}
// Authenticates storage client's requests.
func storageServerRequestAuthenticate(r *http.Request) error {
_, _, err := webRequestAuthenticate(r)
return err
}
// IsValid - To authenticate and verify the time difference.
func (s *storageRESTServer) IsValid(w http.ResponseWriter, r *http.Request) bool {
if err := storageServerRequestAuthenticate(r); err != nil {
w.WriteHeader(http.StatusForbidden)
return false
}
requestTimeStr := r.Header.Get("X-Minio-Time")
requestTime, err := time.Parse(time.RFC3339, requestTimeStr)
if err != nil {

Loading…
Cancel
Save