mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
signature-v2: Use request.RequestURI for signature calculation. (#3616)
* signature-v2: Use request.RequestURI for signature calculation. * Use splitStr instead of strings.Split
This commit is contained in:
committed by
Harshavardhana
parent
fc6f804865
commit
8489f22fe2
@@ -85,16 +85,9 @@ func doesPresignV2SignatureMatch(r *http.Request) APIErrorCode {
|
||||
// Access credentials.
|
||||
cred := serverConfig.GetCredential()
|
||||
|
||||
// url.RawPath will be valid if path has any encoded characters, if not it will
|
||||
// be empty - in which case we need to consider url.Path (bug in net/http?)
|
||||
encodedResource := r.URL.RawPath
|
||||
encodedQuery := r.URL.RawQuery
|
||||
if encodedResource == "" {
|
||||
splits := strings.Split(r.URL.Path, "?")
|
||||
if len(splits) > 0 {
|
||||
encodedResource = getURLEncodedName(splits[0])
|
||||
}
|
||||
}
|
||||
// r.RequestURI will have raw encoded URI as sent by the client.
|
||||
splits := splitStr(r.RequestURI, "?", 2)
|
||||
encodedResource, encodedQuery := splits[0], splits[1]
|
||||
|
||||
queries := strings.Split(encodedQuery, "&")
|
||||
var filteredQueries []string
|
||||
@@ -213,19 +206,9 @@ func doesSignV2Match(r *http.Request) APIErrorCode {
|
||||
return apiError
|
||||
}
|
||||
|
||||
// Encode path:
|
||||
// url.RawPath will be valid if path has any encoded characters, if not it will
|
||||
// be empty - in which case we need to consider url.Path (bug in net/http?)
|
||||
encodedResource := r.URL.RawPath
|
||||
if encodedResource == "" {
|
||||
splits := strings.Split(r.URL.Path, "?")
|
||||
if len(splits) > 0 {
|
||||
encodedResource = getURLEncodedName(splits[0])
|
||||
}
|
||||
}
|
||||
|
||||
// Encode query strings
|
||||
encodedQuery := r.URL.Query().Encode()
|
||||
// r.RequestURI will have raw encoded URI as sent by the client.
|
||||
splits := splitStr(r.RequestURI, "?", 2)
|
||||
encodedResource, encodedQuery := splits[0], splits[1]
|
||||
|
||||
expectedAuth := signatureV2(r.Method, encodedResource, encodedQuery, r.Header)
|
||||
if v2Auth != expectedAuth {
|
||||
|
||||
Reference in New Issue
Block a user