mirror of
https://github.com/minio/minio.git
synced 2025-04-25 04:33:20 -04:00
handlers: Handle re-direction properly for S3 requests. (#3355)
Make sure all S3 signature requests are not re-directed to `/minio`. This should be only done for JWT and some Anonymous requests. This also fixes a bug found from https://github.com/bji/libs3 ``` $ s3 -u list ERROR: XmlParseFailure ``` Now after this fix shows proper output ``` $ s3 -u list Bucket Created -------------------------------------------------------- -------------------- andoria 2016-11-27T08:19:06Z ```
This commit is contained in:
parent
f3322e94c8
commit
201a20ac02
@ -81,8 +81,11 @@ func setBrowserRedirectHandler(h http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
aType := getRequestAuthType(r)
|
||||||
|
// Re-direct only for JWT and anonymous requests coming from web-browser.
|
||||||
|
if aType == authTypeJWT || aType == authTypeAnonymous {
|
||||||
// Re-direction handled specifically for browsers.
|
// Re-direction handled specifically for browsers.
|
||||||
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && !isRequestSignatureV4(r) {
|
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") {
|
||||||
switch r.URL.Path {
|
switch r.URL.Path {
|
||||||
case "/", "/webrpc", "/login", "/favicon.ico":
|
case "/", "/webrpc", "/login", "/favicon.ico":
|
||||||
// '/' is redirected to 'locationPrefix/'
|
// '/' is redirected to 'locationPrefix/'
|
||||||
@ -99,6 +102,7 @@ func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
h.handler.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user