minio/cmd/gateway/s3
Andreas Auernhammer d4b822d697
pkg/etag: add new package for S3 ETag handling (#11577)
This commit adds a new package `etag` for dealing
with S3 ETags.

Even though ETag is often viewed as MD5 checksum of
an object, handling S3 ETags correctly is a surprisingly
complex task. While it is true that the ETag corresponds
to the MD5 for the most basic S3 API operations, there are
many exceptions in case of multipart uploads or encryption.

In worse, some S3 clients expect very specific behavior when
it comes to ETags. For example, some clients expect that the
ETag is a double-quoted string and fail otherwise.
Non-AWS compliant ETag handling has been a source of many bugs
in the past.

Therefore, this commit adds a dedicated `etag` package that provides
functionality for parsing, generating and converting S3 ETags.
Further, this commit removes the ETag computation from the `hash`
package. Instead, the `hash` package (i.e. `hash.Reader`) should
focus only on computing and verifying the content-sha256.

One core feature of this commit is to provide a mechanism to
communicate a computed ETag from a low-level `io.Reader` to
a high-level `io.Reader`.

This problem occurs when an S3 server receives a request and
has to compute the ETag of the content. However, the server
may also wrap the initial body with several other `io.Reader`,
e.g. when encrypting or compressing the content:
```
   reader := Encrypt(Compress(ETag(content)))
```
In such a case, the ETag should be accessible by the high-level
`io.Reader`.

The `etag` provides a mechanism to wrap `io.Reader` implementations
such that the `ETag` can be accessed by a type-check.
This technique is applied to the PUT, COPY and Upload handlers.
2021-02-23 12:31:53 -08:00
..
gateway-s3-metadata.go pkg/etag: add new package for S3 ETag handling (#11577) 2021-02-23 12:31:53 -08:00
gateway-s3-metadata_test.go use GlobalContext whenever possible (#9280) 2020-04-09 09:30:02 -07:00
gateway-s3-sse.go fix: replication metadata comparsion and other fixes (#11410) 2021-02-03 20:41:33 -08:00
gateway-s3-utils.go add gateway object tagging support (#9124) 2020-05-23 11:09:35 -07:00
gateway-s3.go fix: update minio-go to fix an issue with S3 gateway (#11591) 2021-02-20 11:10:21 -08:00
gateway-s3_test.go Move dependency from minio-go v6 to v7 (#10042) 2020-07-14 09:38:05 -07:00