Skip to content

Commit 660d3f3

Browse files
authored
merge: Merge pull request #209 from arunaengine/fix/cors_overwrite
Fix/cors overwrite
2 parents d5dc515 + a15d68d commit 660d3f3

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

components/data_proxy/src/caching/grpc_query_handler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,16 @@ impl GrpcQueryHandler {
512512
variant: KeyValueVariant::Label as i32,
513513
};
514514

515+
let remove_key_values = obj
516+
.key_values
517+
.into_iter()
518+
.filter(|k| k.key == "app.aruna-storage.org/cors")
519+
.collect();
520+
515521
let mut req = Request::new(UpdateProjectKeyValuesRequest {
516522
project_id: obj.id.to_string(),
517523
add_key_values: vec![kv],
518-
remove_key_values: vec![],
524+
remove_key_values,
519525
});
520526

521527
Self::add_token_to_md(req.metadata_mut(), token)?;

components/server/src/middlelayer/relations_request_types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ impl ModifyRelations {
5353
&self.0.add_relations,
5454
resource_id,
5555
transaction_client,
56+
DbPermissionLevel::APPEND,
5657
)
5758
.await?;
5859
let (external_rm_relations, temp_rm_int_relations, mut removed_to_check) =
5960
ModifyRelations::convert_relations(
6061
&self.0.remove_relations,
6162
resource_id,
6263
transaction_client,
64+
DbPermissionLevel::WRITE,
6365
)
6466
.await?;
6567
if !temp_rm_int_relations
@@ -101,6 +103,7 @@ impl ModifyRelations {
101103
api_relations: &Vec<Relation>,
102104
resource_id: DieselUlid,
103105
transaction_client: &Client,
106+
permission_level: DbPermissionLevel,
104107
) -> Result<(Vec<ExternalRelation>, Vec<InternalRelation>, Vec<Context>)> {
105108
let mut external_relations: Vec<ExternalRelation> = Vec::new();
106109
let mut internal_relations: Vec<InternalRelation> = Vec::new();
@@ -114,7 +117,7 @@ impl ModifyRelations {
114117
relation::Relation::Internal(internal) => {
115118
resources_to_check.push(Context::res_ctx(
116119
DieselUlid::from_str(&internal.resource_id)?,
117-
DbPermissionLevel::WRITE,
120+
permission_level,
118121
true,
119122
));
120123
internal_relations

components/server/src/middlelayer/update_db_handler.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ impl DatabaseHandler {
160160
"Both add_key_values and remove_key_values are empty.",
161161
));
162162
}
163+
if !rm_key_values.0.is_empty() {
164+
let object = Object::get(id, transaction_client)
165+
.await?
166+
.ok_or(anyhow!("Dataset does not exist."))?;
167+
for kv in rm_key_values.0 {
168+
if kv.variant == KeyValueVariant::STATIC_LABEL {
169+
return Err(anyhow!("Cannot remove static labels."));
170+
}
171+
if kv.variant == KeyValueVariant::HOOK_STATUS {
172+
return Err(anyhow!(
173+
"Cannot remove hook_status outside of hook_callback"
174+
));
175+
}
176+
object.remove_key_value(transaction_client, kv).await?;
177+
}
178+
}
163179
if !add_key_values.0.is_empty() {
164180
for kv in add_key_values.0 {
165181
match kv.variant {
@@ -182,22 +198,6 @@ impl DatabaseHandler {
182198
}
183199
}
184200

185-
if !rm_key_values.0.is_empty() {
186-
let object = Object::get(id, transaction_client)
187-
.await?
188-
.ok_or(anyhow!("Dataset does not exist."))?;
189-
for kv in rm_key_values.0 {
190-
if kv.variant == KeyValueVariant::STATIC_LABEL {
191-
return Err(anyhow!("Cannot remove static labels."));
192-
}
193-
if kv.variant == KeyValueVariant::HOOK_STATUS {
194-
return Err(anyhow!(
195-
"Cannot remove hook_status outside of hook_callback"
196-
));
197-
}
198-
object.remove_key_value(transaction_client, kv).await?;
199-
}
200-
}
201201
self.evaluate_rules(&vec![id], transaction_client).await?;
202202
transaction.commit().await?;
203203

0 commit comments

Comments
 (0)