|
|
@ -20,7 +20,6 @@ import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"path/filepath" |
|
|
|
|
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
@ -30,7 +29,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
iso8601Format = "20060102T150405Z" |
|
|
|
iso8601Format = "20060102T150405Z" |
|
|
|
privateBucket = "minio" |
|
|
|
privateBucket = "/minio" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// HandlerFunc - useful to chain different middleware http.Handler
|
|
|
|
// HandlerFunc - useful to chain different middleware http.Handler
|
|
|
@ -101,14 +100,12 @@ 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) { |
|
|
|
// Re-direction handled specifically for browsers.
|
|
|
|
// Re-direction handled specifically for browsers.
|
|
|
|
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") { |
|
|
|
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") { |
|
|
|
// Following re-direction code handles redirects only for
|
|
|
|
// '/' is redirected to 'locationPrefix/'
|
|
|
|
// these specific incoming URLs.
|
|
|
|
// '/rpc' is redirected to 'locationPrefix/rpc'
|
|
|
|
// '/' is redirected to '/locationPrefix'
|
|
|
|
// '/login' is redirected to 'locationPrefix/login'
|
|
|
|
// '/rpc' is redirected to '/locationPrefix/rpc'
|
|
|
|
|
|
|
|
// '/login' is redirected to '/locationPrefix/login'
|
|
|
|
|
|
|
|
switch r.URL.Path { |
|
|
|
switch r.URL.Path { |
|
|
|
case "/", "/rpc", "/login": |
|
|
|
case "/", "/rpc", "/login": |
|
|
|
location := path.Join(h.locationPrefix, r.URL.Path) |
|
|
|
location := h.locationPrefix + r.URL.Path |
|
|
|
// Redirect to new location.
|
|
|
|
// Redirect to new location.
|
|
|
|
http.Redirect(w, r, location, http.StatusTemporaryRedirect) |
|
|
|
http.Redirect(w, r, location, http.StatusTemporaryRedirect) |
|
|
|
return |
|
|
|
return |
|
|
@ -146,7 +143,7 @@ func setPrivateBucketHandler(h http.Handler) http.Handler { |
|
|
|
|
|
|
|
|
|
|
|
func (h minioPrivateBucketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
|
|
|
func (h minioPrivateBucketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
|
|
|
// For all non browser requests, reject access to 'privateBucket'.
|
|
|
|
// For all non browser requests, reject access to 'privateBucket'.
|
|
|
|
if !strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && filepath.Base(r.URL.Path) == privateBucket { |
|
|
|
if !strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && path.Clean(r.URL.Path) == privateBucket { |
|
|
|
writeErrorResponse(w, r, AllAccessDisabled, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, AllAccessDisabled, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|