-
Notifications
You must be signed in to change notification settings - Fork 23
add compatibility with CEPH S3 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import ( | |
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
var awsAuthorizationCredentialRegexp = regexp.MustCompile("Credential=([a-zA-Z0-9]+)/[0-9]+/([a-z]+-?[a-z]+-?[0-9]+)/s3/aws4_request") | ||
var awsAuthorizationCredentialRegexp = regexp.MustCompile("Credential=([a-zA-Z0-9]+)/[0-9]+/([a-zA-Z-0-9]+)/s3/aws4_request") | ||
var awsAuthorizationSignedHeadersRegexp = regexp.MustCompile("SignedHeaders=([a-zA-Z0-9;-]+)") | ||
|
||
// Handler is a special handler that re-signs any AWS S3 request and sends it upstream | ||
|
@@ -225,9 +225,12 @@ func (h *Handler) buildUpstreamRequest(req *http.Request) (*http.Request, error) | |
return nil, err | ||
} | ||
|
||
//Sanitize fakeReq to remove some white spaces | ||
fakeAuthorizationStr := strings.Replace(strings.Replace(fakeReq.Header["Authorization"][0],", Signature",",Signature",1),", SignedHeaders",",SignedHeaders",1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for improved readability: please split this into one replace operation per line of code Also: please add tests to validate the new and old behaviour. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it 's a dirty workaround because s3cmd send the authorization header without this white spaces... s3cmd work's well with amazon s3. So, do you have any advice about the way to validate it in a test ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could compute a valid signature and then simply add/remove whitespace as you need to make s3cmd happy. See https://github.com/Kriechi/aws-s3-reverse-proxy/blob/master/handler_test.go#L47 and https://github.com/Kriechi/aws-s3-reverse-proxy/blob/master/handler_test.go#L136 for reference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay i will add some tests to validate this |
||
|
||
// Verify that the fake request and the incoming request have the same signature | ||
// This ensures it was sent and signed by a client with correct AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY | ||
cmpResult := subtle.ConstantTimeCompare([]byte(fakeReq.Header["Authorization"][0]), []byte(req.Header["Authorization"][0])) | ||
cmpResult := subtle.ConstantTimeCompare([]byte(fakeAuthorizationStr), []byte(req.Header["Authorization"][0])) | ||
if cmpResult == 0 { | ||
v, _ := httputil.DumpRequest(fakeReq, false) | ||
log.Debugf("Fake request: %v", string(v)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a code comment with sample values for the new less-strict regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i will refactor this and add comments