Add proper router for handling putBucketACLHandler

master
Harshavardhana 9 years ago
parent e719adec8b
commit d18ca4b40d
  1. 8
      server-api-acl.go
  2. 12
      server-api-bucket-handlers.go
  3. 2
      server-api-definitions.go
  4. 14
      server-api-generic-handlers.go
  5. 6
      server-api-resources.go
  6. 5
      server-api-signature-handler.go
  7. 1
      server-router.go

@ -58,21 +58,13 @@ func getACLType(req *http.Request) ACLType {
func getACLTypeString(acl ACLType) string { func getACLTypeString(acl ACLType) string {
switch acl { switch acl {
case privateACLType: case privateACLType:
{
return "private" return "private"
}
case publicReadACLType: case publicReadACLType:
{
return "public-read" return "public-read"
}
case publicReadWriteACLType: case publicReadWriteACLType:
{
return "public-read-write" return "public-read-write"
}
case unsupportedACLType: case unsupportedACLType:
{
return "" return ""
}
default: default:
return "private" return "private"
} }

@ -222,17 +222,11 @@ func (api API) PutBucketHandler(w http.ResponseWriter, req *http.Request) {
<-op.ProceedCh <-op.ProceedCh
} }
// uncomment this when we have webcli if _, err := stripAccessKeyID(req.Header.Get("Authorization")); err != nil {
// without access key credentials one cannot create a bucket writeErrorResponse(w, req, AccessDenied, req.URL.Path)
// if _, err := StripAccessKeyID(req); err != nil {
// writeErrorResponse(w, req, AccessDenied, req.URL.Path)
// return
// }
if isRequestBucketACL(req.URL.Query()) {
api.PutBucketACLHandler(w, req)
return return
} }
// read from 'x-amz-acl' // read from 'x-amz-acl'
aclType := getACLType(req) aclType := getACLType(req)
if aclType == unsupportedACLType { if aclType == unsupportedACLType {

@ -192,4 +192,6 @@ var notimplementedBucketResourceNames = map[string]bool{
// List of not implemented object queries // List of not implemented object queries
var notimplementedObjectResourceNames = map[string]bool{ var notimplementedObjectResourceNames = map[string]bool{
"torrent": true, "torrent": true,
"acl": true,
"policy": true,
} }

@ -19,6 +19,7 @@ package main
import ( import (
"errors" "errors"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/rs/cors" "github.com/rs/cors"
@ -113,10 +114,21 @@ func IgnoreResourcesHandler(h http.Handler) http.Handler {
// Resource handler ServeHTTP() wrapper // Resource handler ServeHTTP() wrapper
func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if ignoreNotImplementedObjectResources(r) || ignoreNotImplementedBucketResources(r) { splits := strings.SplitN(r.URL.Path, "/", 3)
switch len(splits) {
// bucket exists
case 2:
if ignoreNotImplementedBucketResources(r) {
writeErrorResponse(w, r, NotImplemented, r.URL.Path) writeErrorResponse(w, r, NotImplemented, r.URL.Path)
return return
} }
// object exists
case 3:
if ignoreNotImplementedObjectResources(r) {
writeErrorResponse(w, r, NotImplemented, r.URL.Path)
return
}
}
h.handler.ServeHTTP(w, r) h.handler.ServeHTTP(w, r)
} }

@ -58,9 +58,3 @@ func isRequestUploads(values url.Values) bool {
_, ok := values["uploads"] _, ok := values["uploads"]
return ok return ok
} }
// check if req query values carry acl resource
func isRequestBucketACL(values url.Values) bool {
_, ok := values["acl"]
return ok
}

@ -17,6 +17,8 @@
package main package main
import ( import (
"crypto/sha256"
"encoding/hex"
"net/http" "net/http"
"github.com/minio/minio/pkg/probe" "github.com/minio/minio/pkg/probe"
@ -71,7 +73,8 @@ func (s signatureHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
ok, err := signature.DoesSignatureMatch("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") value := sha256.Sum256([]byte(""))
ok, err := signature.DoesSignatureMatch(hex.EncodeToString(value[:]))
if err != nil { if err != nil {
errorIf(err.Trace(), "Unable to verify signature.", nil) errorIf(err.Trace(), "Unable to verify signature.", nil)
writeErrorResponse(w, r, InternalError, r.URL.Path) writeErrorResponse(w, r, InternalError, r.URL.Path)

@ -29,6 +29,7 @@ import (
func registerAPI(mux *router.Router, a API) { func registerAPI(mux *router.Router, a API) {
mux.HandleFunc("/", a.ListBucketsHandler).Methods("GET") mux.HandleFunc("/", a.ListBucketsHandler).Methods("GET")
mux.HandleFunc("/{bucket}", a.ListObjectsHandler).Methods("GET") mux.HandleFunc("/{bucket}", a.ListObjectsHandler).Methods("GET")
mux.HandleFunc("/{bucket}", a.PutBucketACLHandler).Queries("acl", "").Methods("PUT")
mux.HandleFunc("/{bucket}", a.PutBucketHandler).Methods("PUT") mux.HandleFunc("/{bucket}", a.PutBucketHandler).Methods("PUT")
mux.HandleFunc("/{bucket}", a.HeadBucketHandler).Methods("HEAD") mux.HandleFunc("/{bucket}", a.HeadBucketHandler).Methods("HEAD")
mux.HandleFunc("/{bucket}", a.PostPolicyBucketHandler).Methods("POST") mux.HandleFunc("/{bucket}", a.PostPolicyBucketHandler).Methods("POST")

Loading…
Cancel
Save