aboutsummaryrefslogtreecommitdiff
path: root/src/api/api_server.rs
diff options
context:
space:
mode:
authortrinity-1686a <trinity.pointard@gmail.com>2022-02-21 23:02:30 +0100
committerAlex <alex@adnab.me>2022-02-21 23:02:30 +0100
commitf6f8b7f1ad865f629bdfd93ec1e28a526a5eab37 (patch)
treeb80fef17e63b25c6ba73bb4463660f7356bcabd4 /src/api/api_server.rs
parente312ba977e2c99d3d0b3734f500369c3cd697d0d (diff)
downloadgarage-f6f8b7f1ad865f629bdfd93ec1e28a526a5eab37.tar.gz
garage-f6f8b7f1ad865f629bdfd93ec1e28a526a5eab37.zip
Support for PostObject (#222)
Add support for [PostObject](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html) - [x] routing PostObject properly - [x] parsing multipart body - [x] validating signature - [x] validating policy - [x] validating content length - [x] actually saving data Co-authored-by: trinity-1686a <trinity@deuxfleurs.fr> Co-authored-by: Trinity Pointard <trinity.pointard@gmail.com> Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/222 Reviewed-by: Alex <alex@adnab.me> Co-authored-by: trinity-1686a <trinity.pointard@gmail.com> Co-committed-by: trinity-1686a <trinity.pointard@gmail.com>
Diffstat (limited to 'src/api/api_server.rs')
-rw-r--r--src/api/api_server.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 315116c8..77587de8 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -25,6 +25,7 @@ use crate::s3_cors::*;
use crate::s3_delete::*;
use crate::s3_get::*;
use crate::s3_list::*;
+use crate::s3_post_object::handle_post_object;
use crate::s3_put::*;
use crate::s3_router::{Authorization, Endpoint};
use crate::s3_website::*;
@@ -92,11 +93,6 @@ async fn handler(
}
async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<Body>, Error> {
- let (api_key, content_sha256) = check_payload_signature(&garage, &req).await?;
- let api_key = api_key.ok_or_else(|| {
- Error::Forbidden("Garage does not support anonymous access yet".to_string())
- })?;
-
let authority = req
.headers()
.get(header::HOST)
@@ -115,6 +111,15 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
let (endpoint, bucket_name) = Endpoint::from_request(&req, bucket_name.map(ToOwned::to_owned))?;
debug!("Endpoint: {:?}", endpoint);
+ if let Endpoint::PostObject {} = endpoint {
+ return handle_post_object(garage, req, bucket_name.unwrap()).await;
+ }
+
+ let (api_key, content_sha256) = check_payload_signature(&garage, &req).await?;
+ let api_key = api_key.ok_or_else(|| {
+ Error::Forbidden("Garage does not support anonymous access yet".to_string())
+ })?;
+
let bucket_name = match bucket_name {
None => return handle_request_without_bucket(garage, req, api_key, endpoint).await,
Some(bucket) => bucket.to_string(),