feat(bucket-tenants): add persisted bucket-scoped tenant credentials with bucket export and import APIs
This commit is contained in:
@@ -57,6 +57,7 @@ pub struct RequestContext {
|
||||
pub action: StorageAction,
|
||||
pub bucket: Option<String>,
|
||||
pub key: Option<String>,
|
||||
pub source_bucket: Option<String>,
|
||||
}
|
||||
|
||||
impl RequestContext {
|
||||
@@ -90,6 +91,7 @@ pub fn resolve_action(req: &Request<Incoming>) -> RequestContext {
|
||||
action: StorageAction::ListAllMyBuckets,
|
||||
bucket: None,
|
||||
key: None,
|
||||
source_bucket: None,
|
||||
}
|
||||
}
|
||||
1 => {
|
||||
@@ -113,6 +115,7 @@ pub fn resolve_action(req: &Request<Incoming>) -> RequestContext {
|
||||
action,
|
||||
bucket: Some(bucket),
|
||||
key: None,
|
||||
source_bucket: None,
|
||||
}
|
||||
}
|
||||
2 => {
|
||||
@@ -123,6 +126,18 @@ pub fn resolve_action(req: &Request<Incoming>) -> RequestContext {
|
||||
let has_part_number = query.contains_key("partNumber");
|
||||
let has_upload_id = query.contains_key("uploadId");
|
||||
let has_uploads = query.contains_key("uploads");
|
||||
let source_bucket = if has_copy_source {
|
||||
req.headers()
|
||||
.get("x-amz-copy-source")
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.map(|source| {
|
||||
let source = source.trim_start_matches('/');
|
||||
let first_slash = source.find('/').unwrap_or(source.len());
|
||||
percent_decode(&source[..first_slash])
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let action = match &method {
|
||||
&Method::PUT if has_part_number && has_upload_id => StorageAction::UploadPart,
|
||||
@@ -141,12 +156,14 @@ pub fn resolve_action(req: &Request<Incoming>) -> RequestContext {
|
||||
action,
|
||||
bucket: Some(bucket),
|
||||
key: Some(key),
|
||||
source_bucket,
|
||||
}
|
||||
}
|
||||
_ => RequestContext {
|
||||
action: StorageAction::ListAllMyBuckets,
|
||||
bucket: None,
|
||||
key: None,
|
||||
source_bucket: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user