mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-05 20:37:41 +00:00
Small changes in key model and refactoring
This commit is contained in:
@@ -38,8 +38,8 @@ pub fn handle_get_bucket_versioning() -> Result<Response<Body>, Error> {
|
||||
}
|
||||
|
||||
pub async fn handle_list_buckets(garage: &Garage, api_key: &Key) -> Result<Response<Body>, Error> {
|
||||
let key_state = api_key.state.as_option().ok_or_internal_error(
|
||||
"Key should not be in deleted state at this point (internal error)",
|
||||
let key_p = api_key.params().ok_or_internal_error(
|
||||
"Key should not be in deleted state at this point (in handle_list_buckets)",
|
||||
)?;
|
||||
|
||||
// Collect buckets user has access to
|
||||
@@ -74,7 +74,7 @@ pub async fn handle_list_buckets(garage: &Garage, api_key: &Key) -> Result<Respo
|
||||
}
|
||||
}
|
||||
|
||||
for (alias, _, id_opt) in key_state.local_aliases.items() {
|
||||
for (alias, _, id_opt) in key_p.local_aliases.items() {
|
||||
if let Some(id) = id_opt {
|
||||
aliases.insert(alias.clone(), *id);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ pub async fn handle_list_buckets(garage: &Garage, api_key: &Key) -> Result<Respo
|
||||
// Generate response
|
||||
let list_buckets = s3_xml::ListAllMyBucketsResult {
|
||||
owner: s3_xml::Owner {
|
||||
display_name: s3_xml::Value(api_key.name.get().to_string()),
|
||||
display_name: s3_xml::Value(key_p.name.get().to_string()),
|
||||
id: s3_xml::Value(api_key.key_id.to_string()),
|
||||
},
|
||||
buckets: s3_xml::BucketList {
|
||||
|
||||
@@ -66,6 +66,7 @@ pub async fn check_signature(
|
||||
.await?
|
||||
.filter(|k| !k.state.is_deleted())
|
||||
.ok_or_else(|| Error::Forbidden(format!("No such key: {}", authorization.key_id)))?;
|
||||
let key_p = key.params().unwrap();
|
||||
|
||||
let canonical_request = canonical_request(
|
||||
request.method(),
|
||||
@@ -79,7 +80,7 @@ pub async fn check_signature(
|
||||
|
||||
let mut hmac = signing_hmac(
|
||||
&date,
|
||||
&key.secret_key,
|
||||
&key_p.secret_key,
|
||||
&garage.config.s3_api.s3_region,
|
||||
"s3",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user