mirror of
https://github.com/minio/minio.git
synced 2025-02-04 02:15:59 -05:00
Validate incoming requests (#7234)
This commit is contained in:
parent
118270d76f
commit
14544d8d84
@ -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…
x
Reference in New Issue
Block a user