s3cmd: Handle support for s3cmd.

This commit is contained in:
Harshavardhana
2015-12-09 15:38:40 -08:00
parent 7187668828
commit 3c71c5c80c
6 changed files with 63 additions and 12 deletions
+21
View File
@@ -46,6 +46,10 @@ type resourceHandler struct {
handler http.Handler
}
type ignoreSignatureV2RequestHandler struct {
handler http.Handler
}
func parseDate(req *http.Request) (time.Time, error) {
amzDate := req.Header.Get(http.CanonicalHeaderKey("x-amz-date"))
switch {
@@ -128,6 +132,23 @@ func CorsHandler(h http.Handler) http.Handler {
return c.Handler(h)
}
// IgnoreSignatureV2RequestHandler -
// Verify if authorization header has signature version '2', reject it cleanly.
func IgnoreSignatureV2RequestHandler(h http.Handler) http.Handler {
return ignoreSignatureV2RequestHandler{h}
}
// Ignore signature version '2' ServerHTTP() wrapper.
func (h ignoreSignatureV2RequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if _, ok := r.Header["Authorization"]; ok {
if !strings.HasPrefix(r.Header.Get("Authorization"), authHeaderPrefix) {
writeErrorResponse(w, r, SignatureVersionNotSupported, r.URL.Path)
return
}
}
h.handler.ServeHTTP(w, r)
}
// IgnoreResourcesHandler -
// Ignore resources handler is wrapper handler used for API request resource validation
// Since we do not support all the S3 queries, it is necessary for us to throw back a