kopia lustrzana https://github.com/gaul/s3proxy
Handle listing a public-read container
Also handle checking existence.pull/86/head
rodzic
0faa68ccfc
commit
274bf8a32e
|
@ -287,7 +287,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// anonymous request
|
// anonymous request
|
||||||
if (method.equals("GET") &&
|
if ((method.equals("GET") || method.equals("HEAD")) &&
|
||||||
request.getHeader(HttpHeaders.AUTHORIZATION) == null &&
|
request.getHeader(HttpHeaders.AUTHORIZATION) == null &&
|
||||||
request.getParameter("AWSAccessKeyId") == null &&
|
request.getParameter("AWSAccessKeyId") == null &&
|
||||||
defaultBlobStore != null) {
|
defaultBlobStore != null) {
|
||||||
|
@ -522,11 +522,18 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
String[] path = uri.split("/", 3);
|
String[] path = uri.split("/", 3);
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "GET":
|
case "GET":
|
||||||
if (path.length <= 1) {
|
if (uri.equals("/")) {
|
||||||
throw new S3Exception(S3ErrorCode.INVALID_REQUEST);
|
|
||||||
} else if (path.length == 2) {
|
|
||||||
handleContainerList(response, blobStore);
|
handleContainerList(response, blobStore);
|
||||||
return;
|
return;
|
||||||
|
} else if (path.length <= 2 || path[2].isEmpty()) {
|
||||||
|
String containerName = path[1];
|
||||||
|
ContainerAccess access = blobStore.getContainerAccess(
|
||||||
|
containerName);
|
||||||
|
if (access == ContainerAccess.PRIVATE) {
|
||||||
|
throw new S3Exception(S3ErrorCode.ACCESS_DENIED);
|
||||||
|
}
|
||||||
|
handleBlobList(request, response, blobStore, containerName);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlobRequestSigner signer = blobStore
|
BlobRequestSigner signer = blobStore
|
||||||
|
@ -570,6 +577,20 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case "HEAD":
|
||||||
|
if (path.length <= 2 || path[2].isEmpty()) {
|
||||||
|
String containerName = path[1];
|
||||||
|
ContainerAccess access = blobStore.getContainerAccess(
|
||||||
|
containerName);
|
||||||
|
if (access == ContainerAccess.PRIVATE) {
|
||||||
|
throw new S3Exception(S3ErrorCode.ACCESS_DENIED);
|
||||||
|
}
|
||||||
|
if (!blobStore.containerExists(containerName)) {
|
||||||
|
throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue