@@ -21,9 +21,9 @@ use crate::{
2121 TaskEntityNamed , TaskFilter , TaskId , TaskOutcome as TQTaskOutcome , TaskQueueName ,
2222 TaskStatus as TQTaskStatus ,
2323 } ,
24- CatalogStore , CatalogTabularOps , CatalogTaskOps , InvalidTabularIdentifier , ResolvedTask ,
25- Result , SecretStore , State , TableNamed , TabularId , TabularListFlags , Transaction ,
26- ViewNamed , ViewOrTableInfo ,
24+ CatalogStore , CatalogTabularOps , CatalogTaskOps , CatalogWarehouseOps ,
25+ InvalidTabularIdentifier , ResolvedTask , ResolvedWarehouse , Result , SecretStore , State ,
26+ TableNamed , TabularId , TabularListFlags , Transaction , ViewNamed , ViewOrTableInfo ,
2727 } ,
2828 WarehouseId ,
2929} ;
@@ -350,11 +350,15 @@ pub(crate) trait Service<C: CatalogStore, A: Authorizer, S: SecretStore> {
350350 // -------------------- AUTHZ --------------------
351351 let authorizer = context. v1_state . authz ;
352352
353+ let warehouse =
354+ C :: get_active_warehouse_by_id ( warehouse_id, context. v1_state . catalog . clone ( ) ) . await ;
355+ let warehouse = authorizer. require_warehouse_presence ( warehouse_id, warehouse) ?;
356+
353357 authorize_list_tasks :: < A , C > (
354358 & authorizer,
355359 context. v1_state . catalog . clone ( ) ,
356360 & request_metadata,
357- warehouse_id ,
361+ & warehouse ,
358362 query. entities . as_ref ( ) ,
359363 )
360364 . await ?;
@@ -377,12 +381,16 @@ pub(crate) trait Service<C: CatalogStore, A: Authorizer, S: SecretStore> {
377381 // -------------------- AUTHZ --------------------
378382 let authorizer = context. v1_state . authz ;
379383
384+ let warehouse =
385+ C :: get_active_warehouse_by_id ( warehouse_id, context. v1_state . catalog . clone ( ) ) . await ;
386+ let warehouse = authorizer. require_warehouse_presence ( warehouse_id, warehouse) ?;
387+
380388 let [ authz_can_use, authz_get_all_warehouse] = authorizer
381389 . are_allowed_warehouse_actions_arr (
382390 & request_metadata,
383391 & [
384- ( warehouse_id , CatalogWarehouseAction :: CanUse ) ,
385- ( warehouse_id , CAN_GET_ALL_TASKS_DETAILS_WAREHOUSE_PERMISSION ) ,
392+ ( & warehouse , CatalogWarehouseAction :: CanUse ) ,
393+ ( & warehouse , CAN_GET_ALL_TASKS_DETAILS_WAREHOUSE_PERMISSION ) ,
386394 ] ,
387395 )
388396 . await ?
@@ -437,12 +445,16 @@ pub(crate) trait Service<C: CatalogStore, A: Authorizer, S: SecretStore> {
437445 // -------------------- AUTHZ --------------------
438446 let authorizer = context. v1_state . authz ;
439447
448+ let warehouse =
449+ C :: get_active_warehouse_by_id ( warehouse_id, context. v1_state . catalog . clone ( ) ) . await ;
450+ let warehouse = authorizer. require_warehouse_presence ( warehouse_id, warehouse) ?;
451+
440452 let [ authz_can_use, authz_control_all] = authorizer
441453 . are_allowed_warehouse_actions_arr (
442454 & request_metadata,
443455 & [
444- ( warehouse_id , CatalogWarehouseAction :: CanUse ) ,
445- ( warehouse_id , CONTROL_TASK_WAREHOUSE_PERMISSION ) ,
456+ ( & warehouse , CatalogWarehouseAction :: CanUse ) ,
457+ ( & warehouse , CONTROL_TASK_WAREHOUSE_PERMISSION ) ,
446458 ] ,
447459 )
448460 . await ?
@@ -518,15 +530,17 @@ async fn authorize_list_tasks<A: Authorizer, C: CatalogStore>(
518530 authorizer : & A ,
519531 catalog_state : C :: State ,
520532 request_metadata : & RequestMetadata ,
521- warehouse_id : WarehouseId ,
533+ warehouse : & ResolvedWarehouse ,
522534 entities : Option < & Vec < TaskEntity > > ,
523535) -> Result < ( ) > {
536+ let warehouse_id = warehouse. warehouse_id ;
537+
524538 let [ can_use, can_list_everything] = authorizer
525539 . are_allowed_warehouse_actions_arr (
526540 request_metadata,
527541 & [
528- ( warehouse_id , CatalogWarehouseAction :: CanUse ) ,
529- ( warehouse_id , CatalogWarehouseAction :: CanListEverything ) ,
542+ ( warehouse , CatalogWarehouseAction :: CanUse ) ,
543+ ( warehouse , CatalogWarehouseAction :: CanListEverything ) ,
530544 ] ,
531545 )
532546 . await ?
0 commit comments