fix: add virtual host style workaround for gorilla/mux issue (#10010)

gorilla/mux broke their recent release 1.7.4 which we
upgraded to, we need the current workaround to ensure
that our regex matches appropriately.

An upstream PR is sent, we should remove the
workaround once we have a new release.
master
Harshavardhana 4 years ago committed by GitHub
parent ba756cf366
commit 36d36fab0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      cmd/api-router.go
  2. 12
      cmd/iam-object-store.go

@ -84,7 +84,15 @@ func registerAPIRouter(router *mux.Router, encryptionEnabled, allowSSEKMS bool)
apiRouter := router.PathPrefix(SlashSeparator).Subrouter() apiRouter := router.PathPrefix(SlashSeparator).Subrouter()
var routers []*mux.Router var routers []*mux.Router
for _, domainName := range globalDomainNames { for _, domainName := range globalDomainNames {
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName).Subrouter()) if globalMinioPort == "80" || globalMinioPort == "443" {
// For standard ports its possible, incoming requests
// might not have a port assigned, in such scenarios use
// have wildcard routing.
// FIXME: remove this code once https://github.com/gorilla/mux/pull/579
// is merged and released upstream, as this entire change can become
// a single line.
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName).Subrouter())
}
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName+":{port:.*}").Subrouter()) routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName+":{port:.*}").Subrouter())
} }
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter()) routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())

@ -256,8 +256,7 @@ func (iamOS *IAMObjectStore) loadPolicyDocs(ctx context.Context, m map[string]ia
} }
policyName := item.Item policyName := item.Item
err := iamOS.loadPolicyDoc(policyName, m) if err := iamOS.loadPolicyDoc(policyName, m); err != nil && err != errNoSuchPolicy {
if err != nil {
return err return err
} }
} }
@ -325,8 +324,7 @@ func (iamOS *IAMObjectStore) loadUsers(ctx context.Context, userType IAMUserType
} }
userName := item.Item userName := item.Item
err := iamOS.loadUser(userName, userType, m) if err := iamOS.loadUser(userName, userType, m); err != errNoSuchUser {
if err != nil {
return err return err
} }
} }
@ -353,8 +351,7 @@ func (iamOS *IAMObjectStore) loadGroups(ctx context.Context, m map[string]GroupI
} }
group := item.Item group := item.Item
err := iamOS.loadGroup(group, m) if err := iamOS.loadGroup(group, m); err != nil && err != errNoSuchGroup {
if err != nil {
return err return err
} }
} }
@ -397,8 +394,7 @@ func (iamOS *IAMObjectStore) loadMappedPolicies(ctx context.Context, userType IA
policyFile := item.Item policyFile := item.Item
userOrGroupName := strings.TrimSuffix(policyFile, ".json") userOrGroupName := strings.TrimSuffix(policyFile, ".json")
err := iamOS.loadMappedPolicy(userOrGroupName, userType, isGroup, m) if err := iamOS.loadMappedPolicy(userOrGroupName, userType, isGroup, m); err != nil && err != errNoSuchPolicy {
if err != nil && err != errNoSuchPolicy {
return err return err
} }
} }

Loading…
Cancel
Save