This way, the migration uses a timestamp of zero instead of the current timestamp.
- Avoids the migration producing different values on different nodes
- Avoids a migration running after an update canceling out the update
Anonymous access can now be configured by allowing specific S3 methods.
Currently, this only includes `s3:HeadObject` and `s3:GetObject`. Umbrella
grants can also be used that translate to lists of methods (`garage:ReadObject` ->
[`s3:HeadObject`, `s3:GetObject`].
The CLI takes either a list of `--allow`ed methods, or a `--revoke-all`.
`ReqCtx` is now represented by an enum of either an authenticated requests
or an anonymous one. Handlers will take either one of those depending on whether
they allow anonymous access or not. `ReqCtxEnum` implements `TryInto` to transform
into the requested type (where building an anonymous context always works, but
building an authenticated one only works if the request contained valid
credentials).
When building an anonymous context, the bucket anonymous configuration will
be checked against the requested endpoint to check if all required methods are
allowed anonymously.
Path-style URLs of the form /bucket//key address an object whose key begins with "/". Two greedy uses of `trim_start_matches('/')` were collapsing these leading slashes away:
- `uri.path().trim_start_matches('/')` stripped all leading slashes from the raw path before any further parsing.
- `p.trim_start_matches('/')` stripped leading slashes from the remainder after `split_once('/')` had already consumed the bucket/key separator
The combined effect wath that `HEAD /bucket//` and `GET /bucket//` produced an empty key, which the router treated as bucket-level operations (HeadBucket -> 200 OK, and ListObjectsV2) instead of an object-level op (HeadObject/GetObject -> 404 NoSuchKey).
The fix is simple: Replace the first `trim_start_matches` with `strip_prefix` (to strip exactly one separator slash) and remove the second one entirely. Path-style and vhost-style requests are now consistent: a double slash in the URL correctly addresses a key whose name begins with "/".
Regression tests added for `HEAD //` and `GET //` requests in both request styles.
Fixes: #1464
---
Disclaimer: I'm not fluent in Rust and I did use an LLM to explain the code to me. All code was written by me.
I'm not sure whether the large `test_cases!` block in the `test_aws_doc_examples` function is the right place for my tests (it certainly was a convenient one).
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1465