Further fixes for ACL support, currently code is disabled in all the handlers

Disabled because due to lack of testing support. Once we get that in we can
uncomment them back.
This commit is contained in:
Harshavardhana
2015-04-22 19:29:39 -07:00
parent 1c0ff2c758
commit 848c4ee31c
8 changed files with 91 additions and 68 deletions
+1 -24
View File
@@ -20,14 +20,11 @@ import (
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/minio-io/minio/pkg/api/config"
"github.com/minio-io/minio/pkg/storage/drivers"
)
type vHandler struct {
conf config.Config
driver drivers.Driver
handler http.Handler
}
@@ -50,10 +47,9 @@ func stripAccessKey(r *http.Request) string {
// Validate handler is wrapper handler used for API request validation with authorization header.
// Current authorization layer supports S3's standard HMAC based signature request.
func validateHandler(conf config.Config, driver drivers.Driver, h http.Handler) http.Handler {
func validateHandler(conf config.Config, h http.Handler) http.Handler {
return vHandler{
conf: conf,
driver: driver,
handler: h,
}
}
@@ -66,25 +62,6 @@ func (h vHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
writeErrorResponse(w, r, NotAcceptable, acceptsContentType, r.URL.Path)
return
}
// verify for if bucket is private or public
vars := mux.Vars(r)
bucket, ok := vars["bucket"]
if ok {
bucketMetadata, err := h.driver.GetBucketMetadata(bucket)
if err != nil {
writeErrorResponse(w, r, AccessDenied, acceptsContentType, r.URL.Path)
return
}
if accessKey == "" && bucketMetadata.ACL.IsPrivate() {
writeErrorResponse(w, r, AccessDenied, acceptsContentType, r.URL.Path)
return
}
if r.Method == "PUT" && bucketMetadata.ACL.IsPublicRead() {
writeErrorResponse(w, r, AccessDenied, acceptsContentType, r.URL.Path)
return
}
}
switch true {
case accessKey != "":
if err := h.conf.ReadConfig(); err != nil {