Skip to content

Commit

Permalink
Do not check authorization when in anonymous mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gaul committed Oct 11, 2015
1 parent cad436f commit 618c350
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,26 @@ private void doHandle(HttpServletRequest request,
String headerAuthorization = request.getHeader(
HttpHeaders.AUTHORIZATION);

if (headerAuthorization != null) {
if (headerAuthorization.startsWith("AWS ")) {
int colon = headerAuthorization.lastIndexOf(':',
headerAuthorization.length() - 2);
if (colon < 4) {
if (!anonymousIdentity) {
if (headerAuthorization != null) {
if (headerAuthorization.startsWith("AWS ")) {
int colon = headerAuthorization.lastIndexOf(':',
headerAuthorization.length() - 2);
if (colon < 4) {
throw new S3Exception(S3ErrorCode.INVALID_ARGUMENT);
}
requestIdentity = headerAuthorization.substring(4, colon);
requestSignature = headerAuthorization.substring(colon + 1);
} else if (headerAuthorization.startsWith(
"AWS4-HMAC-SHA256 ")) {
// Fail V4 signature requests to allow clients to retry
// with V2.
throw new S3Exception(S3ErrorCode.INVALID_ARGUMENT);
}
requestIdentity = headerAuthorization.substring(4, colon);
requestSignature = headerAuthorization.substring(colon + 1);
} else if (headerAuthorization.startsWith("AWS4-HMAC-SHA256 ")) {
// Fail V4 signature requests to allow clients to retry with V2.
throw new S3Exception(S3ErrorCode.INVALID_ARGUMENT);
} else {
requestIdentity = request.getParameter("AWSAccessKeyId");
requestSignature = request.getParameter("Signature");
}
} else {
requestIdentity = request.getParameter("AWSAccessKeyId");
requestSignature = request.getParameter("Signature");
}

String[] path = uri.split("/", 3);
Expand Down

0 comments on commit 618c350

Please sign in to comment.