Commit Graph

690 Commits

Author SHA1 Message Date
Antoine Popineau d0706be988 Refactor how anonymous access is checked and add granular method grants.
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.
2026-11-25 09:50:48 +01:00
Antoine Popineau 8bf75679b9 Add bucket-level anonymous HTTP access. 2026-11-25 09:50:48 +01:00
Arthur Carcano a3b1711ab8 Fix bug found by fuzzing the object CRDT (fix #1542) (#1541)
Merging this would be a breaking change.

Fixes the bug found in  #1540 (issue #1542)

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1541
2026-11-25 09:50:48 +01:00
Alex Auvolat a5fe811c70 metrics: uniformize _total suffix 2026-11-25 09:50:48 +01:00
Dominik Menke 447a7d97ff fix: improve routing of keys starting with "/" (fix #1178) (#1465)
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
2026-11-25 09:50:48 +01:00
Alex Auvolat 9a4a1a2bdb bump version to v2.6.0 2026-11-24 16:33:30 +01:00
Alex Auvolat f0d76303ae Revert "s3: make blocks 64 bytes shorter to leave space for ZSTD header (fix #1359) (#1623)"
This reverts commit dcde10ac39.
2026-11-22 10:46:04 +01:00
Alex Auvolat 4dde841d01 s3: add missing quota check in copyobject (fix #1621) (#1627)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1627
2026-11-22 09:45:37 +00:00
Alex Auvolat 54e6c5cde4 s3 api: use try_insert() in postobject to avoid panic (fix #1622) (#1626)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1626
2026-11-22 09:45:15 +00:00
Alex Auvolat dcde10ac39 s3: make blocks 64 bytes shorter to leave space for ZSTD header (fix #1359) (#1623)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1623
2026-11-21 16:11:40 +00:00
Alex Auvolat 984cb2afe7 resync: return queue len from ram instead of querying db (fix #1588) (#1619)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1619
2026-11-21 09:58:30 +00:00
Alex Auvolat c957a4a639 s3 api: more robust putobject cancellation handling (fix #1604) (#1620)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1620
2026-11-21 09:55:03 +00:00
RogerSik 09e377d85d s3: stop ListMultipartUploads scan at end of prefix (fix #1560) (#1561)
See #1560

Co-authored-by: Roger Sikorski <roger@sikorski.cloud>
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1561
2026-11-16 13:54:39 +00:00
Alex Auvolat 9d88e74847 s3 api: fix listobjects when startafter is before prefix (fix #1596) (#1608)
also add regression test

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1608
2026-11-16 12:28:44 +00:00
Alex Auvolat 94c3a02709 s3 api: return 501 unimplemented before permission check (fix #1600) (#1607)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1607
2026-11-15 18:38:27 +00:00
Alex Auvolat c27a9d9bc3 admin api: add feature to integrate web ui into build 2026-11-15 16:05:09 +01:00
Mathew Storm 86e613e46d signature: ignore unsigned checksum query params in presigned URLs (fix #1236) 2026-11-07 15:11:00 +00:00
Alex Auvolat 586726edb0 bump version to v2.5.0 2026-10-23 16:47:28 +02:00
Alex Auvolat 96a71b454d conf: rename advertise_endpoint to public_endpoint (#1587)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1587
2026-10-23 14:47:08 +00:00
Alex Auvolat e13aec892d s3: use generate_object_public_url in PostObject (fix #1574) 2026-10-23 15:39:50 +02:00
Alex Auvolat 0db96d16ef signature: add regression unit test for canonical_request invalid utf8 2026-10-23 09:34:13 +00:00
Alex Auvolat c2f0126b2e signature: fix panic with invalid utf8 in url after urldecode 2026-10-23 09:34:13 +00:00
Alex Auvolat 54c928d521 api: be resilient to failures in .accept() (related: #1508) (#1582)
applies the same pattern as in `net/netapp.rs`: when accept() returns an error, log it and continue

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1582
2026-10-22 14:53:59 +00:00
Ísold Varðberg 35e6c2b6cb api/s3: return 500 on composite checksum part count mismatch
Return an internal error instead of a response without the -N suffix
when a composite checksum has no part count, or when a part count is
given for a non-composite checksum. Also add a FIXME about parsing the
part count out of the etag.
2026-10-22 09:00:52 +00:00
Ísold Varðberg 7065d5de6f api/s3: add -N suffix to composite checksums (fix #1228) 2026-10-22 09:00:52 +00:00
Alex Auvolat 7732eb93bb api: fix empty lifecycle configuration causing error 2026-10-16 12:48:31 +02:00
Alex Auvolat a0529ab3c3 s3 api: update router tests with new more restrictive permissions 2026-10-16 12:48:31 +02:00
Alex Auvolat f1549869d3 s3: restrict access to lifecycle configuration endpoints
Credits: MUTED CYBERSECURITY S.L. for reporting that lifecycle
configuration endpoints were accessible with simple `write` permission.

This commit reorganizes permission checking to have explicit lists of
endpoints allowed with `write` access, and require `owner` permissions
for all other endpoints
2026-10-16 12:19:06 +02:00
Alex Auvolat 310fd3b828 web server: make root_domain optional (as per config file) 2026-10-02 12:47:26 +00:00
Alex Auvolat d3f7c380e5 add public endpoint in config and report connection params in GetNodeInfo 2026-10-02 12:47:26 +00:00
Arthur Carcano 889a8e33dd Add the resync queue size to garage status (#1556)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1556
Reviewed-by: Alex <lx@deuxfleurs.fr>
2026-10-02 12:28:06 +00:00
Alex Auvolat 513c83ea20 admin api: replace -WithDetails suffix with -Info 2026-10-01 07:02:56 +00:00
Alex Auvolat b79994cd21 admin api: remove ?details=<bool> and use instead two different endpoints 2026-10-01 07:02:56 +00:00
Alex Auvolat 4d15590de8 Admin API: add parameters details, offset and limit to ListKeys and ListBuckets 2026-10-01 07:02:56 +00:00
maximilien de3d7561c3 trivia: remove unused imports (#1558)
Rust 1.98.1 was complaining about them.

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1558
2026-09-30 07:38:51 +00:00
maximilien 1793cf58bb telemetry: ugrade otel and swap prometheus deps 2026-09-27 07:55:43 +02:00
Alex Auvolat 8531330166 admin api: be more restrictive on valid admin tokens + fix crash 2026-09-25 11:37:58 +02:00
Steffen Vogel 84ba586c34 feat(s3): return x-amz-checksum-type in responses as per AWS S3 spec
Add the missing x-amz-checksum-type response header / ChecksumType XML
element to operations where AWS S3 specifies it:

- PutObject: x-amz-checksum-type: FULL_OBJECT header when the object
  was uploaded with a checksum
- GetObject / HeadObject: x-amz-checksum-type header when the request
  enables x-amz-checksum-mode and the object has a stored checksum type
- CreateMultipartUpload: x-amz-checksum-algorithm and
  x-amz-checksum-type headers when a checksum algorithm was requested
- CopyObject: ChecksumType element (plus the ChecksumCRC32/CRC32C/
  CRC64NVME/SHA1/SHA256 elements) in the CopyObjectResult XML body

UploadPart and UploadPartCopy responses are unchanged, as AWS S3 does
not return a checksum type for part-level operations.

To support this, add_checksum_response_headers() now takes the stored
ChecksumType as an additional parameter.
2026-09-15 11:42:21 +00:00
Steffen Vogel 691451092d fix(s3): correct ChecksumCRC64NVME XML tag name in CompleteMultipartUploadResult
The XML element was serialized as ChecksumCR64NVME instead of
ChecksumCRC64NVME as specified by the AWS S3 API.
2026-09-15 11:42:21 +00:00
trinity-1686a 5d6fb23c18 wrap secrets in new type (#1524)
this allows hiding them from Debug, and to more easily enforce safe usage such as constant time comparison

Co-authored-by: Alex Auvolat <alex@adnab.me>
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1524
Reviewed-by: Alex <lx@deuxfleurs.fr>
2026-09-15 10:37:19 +00:00
Mohamed El tamawey 8a3554e7a9 Report Content-MD5 mismatch on PutObject as BadDigest (fix #1520) (#1538)
I did the bare minimum, meaning I didn't try to implement a fix for other parts (like SHA-256), just to make sure I am on the right track.

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1538
2026-09-15 09:55:50 +00:00
Arthur Carcano 06dc82e3a0 WIP step 3 2026-09-10 15:18:52 +00:00
Alex Auvolat 268334bd25 bump version to v2.4.1 2026-09-07 21:05:12 +02:00
Alex Auvolat 073dd715ce bump version to v2.4.0 and update api json schema 2026-09-06 19:43:04 +02:00
Raj Singh c54077af73 api/s3: don't panic when reading a version with no blocks
body_from_blocks_range indexed all_blocks[0] to size a capacity hint. A
version with zero blocks made that index panic and kill the process on a
plain GET, the read-side twin of the CompleteMultipartUpload panic at
multipart.rs:479. Fall back to the existing 1024 floor when the slice is
empty; with a non-empty slice the hint is unchanged.
2026-09-04 03:19:07 +00:00
Raj Singh f38f001bad api/s3: don't panic when final multipart version has no blocks
CompleteMultipartUpload builds the final version and then reads
`final_version.blocks.items()[0]` unconditionally. When the assembled
version ends up with an empty block list the index panics and the
process dies before it can answer the request:

    panicked at src/api/s3/multipart.rs:479:3:
    index out of bounds: the len is 0 but the index is 0

Use `.first()` and return an internal error instead, matching how the
rest of this file handles missing data. The empty-block case is an
internal consistency condition rather than a malformed request, so it
maps to an internal error rather than a 4xx.

The same panic was reported earlier in #1403, at multipart.rs:483 on
v2.2.0. That report was closed without a fix after the reporter moved
off consistency_mode = "dangerous".

Closes #1521
2026-09-04 00:01:32 +00:00
i5-650 c85597fd18 Better handling of wildcards in CORS rules (fix #1105) (#1516)
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1516
2026-09-03 07:50:59 +00:00
Alex Auvolat aa4e4656b1 GetKeyInfo: properly list locally-aliased buckets even if they have no permissions 2026-07-25 14:24:58 +02:00
Alex Auvolat 5549077d6f GetBucketInfo: properly return keys that have local aliases even if they have no permissions 2026-07-25 14:24:49 +02:00
smattymatty 663fc5ae48 fix(s3): allow UTF-8 in PostObject form field values (fix #1489) (#1492)
PostObject (presigned POST) returns `400 InvalidHeaderValue` when the upload involves a non-ASCII filename. The same key uploads fine vie PUT, as the issue #1489 noted.

The problem was that `handle_post_object` stores the form field values in an `http::HeaderMap`. values go in through `HeaderValue::from_str` but are read back with the strict `HeaderValue::to_str()` (ASCII-only) which fails on any UTF-8 value.

This is the same problem fixed in eab2b81b for `x-amz-meta-*` headers, and the fix is the same:
`std::str::from_utf8(value.as_bytes())` instead of `to_str()`. The `key` field in `post_object.rs` and the standard headers (`content-disposition` etc.) in `extract_metadata_headers`.

Added integration tests for PostObject (there were none): UTF-8 key, `${filename}` substitution, and UTF-8 `Content-Disposition` metadata. The substitution test passes even without the fix, proving that the filename path was never broken, only the form-params round-trip.

Co-authored-by: Mathew Storm <mathew@stormdevelopments.ca>
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1492
Reviewed-by: trinity-1686a <trinity-1686a@noreply.localhost>
2026-07-20 18:12:39 +00:00