mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
redirect to console project for browser (#12172)
This commit is contained in:
parent
9e797532dc
commit
301669cf7b
@ -131,8 +131,26 @@ const (
|
||||
loginPathPrefix = SlashSeparator + "login"
|
||||
)
|
||||
|
||||
// guessIsBrowserReq - returns true if the request is browser.
|
||||
// This implementation just validates user-agent and
|
||||
// looks for "Mozilla" string. This is no way certifiable
|
||||
// way to know if the request really came from a browser
|
||||
// since User-Agent's can be arbitrary. But this is just
|
||||
// a best effort function.
|
||||
func guessIsBrowserReq(req *http.Request) bool {
|
||||
if req == nil {
|
||||
return false
|
||||
}
|
||||
aType := getRequestAuthType(req)
|
||||
return strings.Contains(req.Header.Get("User-Agent"), "Mozilla") && (aType == authTypeJWT || aType == authTypeAnonymous)
|
||||
}
|
||||
|
||||
func setRedirectHandler(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if guessIsBrowserReq(r) {
|
||||
http.Redirect(w, r, "https://github.com/minio/console", http.StatusMovedPermanently)
|
||||
return
|
||||
}
|
||||
if !shouldProxy() || guessIsRPCReq(r) || guessIsHealthCheckReq(r) ||
|
||||
guessIsMetricsReq(r) || isAdminReq(r) {
|
||||
h.ServeHTTP(w, r)
|
||||
|
Loading…
Reference in New Issue
Block a user