@@ -79,12 +79,19 @@ impl DataStore {
7979 pub async fn ip_pools_fetch_default_for (
8080 & self ,
8181 opctx : & OpContext ,
82- action : authz:: Action ,
8382 silo_id : Option < Uuid > ,
8483 project_id : Option < Uuid > ,
8584 ) -> LookupResult < IpPool > {
8685 use db:: schema:: ip_pool:: dsl;
87- opctx. authorize ( action, & authz:: IP_POOL_LIST ) . await ?;
86+
87+ // TODO: Need auth check here. Only fleet viewers can list children on
88+ // IP_POOL_LIST, so if we check that, nobody can make instances. This
89+ // used to check CreateChild on an individual IP pool, but now we're not
90+ // looking up by name so the check is more complicated
91+ //
92+ // opctx
93+ // .authorize(authz::Action::ListChildren, &authz::IP_POOL_LIST)
94+ // .await?;
8895
8996 dsl:: ip_pool
9097 . filter ( dsl:: silo_id. eq ( silo_id) . or ( dsl:: silo_id. is_null ( ) ) )
@@ -114,15 +121,16 @@ impl DataStore {
114121 pub ( crate ) async fn ip_pools_fetch_for (
115122 & self ,
116123 opctx : & OpContext ,
117- action : authz:: Action ,
118124 name : & Name ,
119125 silo_id : Uuid ,
120126 // TODO: project_id should always be defined, this is temporary
121127 project_id : Option < Uuid > ,
122128 ) -> LookupResult < IpPool > {
123129 let ( .., authz_pool, pool) = LookupPath :: new ( opctx, & self )
124130 . ip_pool_name ( & name)
125- . fetch_for ( action)
131+ // any authenticated user can CreateChild on an IP pool. this is
132+ // meant to represent allocating an IP
133+ . fetch_for ( authz:: Action :: CreateChild )
126134 . await ?;
127135
128136 // You can't look up a pool by name if it conflicts with your current
@@ -472,7 +480,6 @@ impl DataStore {
472480
473481#[ cfg( test) ]
474482mod test {
475- use crate :: authz;
476483 use crate :: db:: datastore:: datastore_test;
477484 use crate :: db:: model:: IpPool ;
478485 use assert_matches:: assert_matches;
@@ -487,12 +494,10 @@ mod test {
487494 let mut db = test_setup_database ( & logctx. log ) . await ;
488495 let ( opctx, datastore) = datastore_test ( & logctx, & db) . await ;
489496
490- let action = authz:: Action :: ListChildren ;
491-
492497 // we start out with the default fleet-level pool already created,
493498 // so when we ask for the fleet default (no silo or project) we get it back
494499 let fleet_default_pool = datastore
495- . ip_pools_fetch_default_for ( & opctx, action , None , None )
500+ . ip_pools_fetch_default_for ( & opctx, None , None )
496501 . await
497502 . unwrap ( ) ;
498503
@@ -523,7 +528,7 @@ mod test {
523528 // has no default of its own
524529 let silo_id = opctx. authn . silo_required ( ) . unwrap ( ) . id ( ) ;
525530 let ip_pool = datastore
526- . ip_pools_fetch_default_for ( & opctx, action , Some ( silo_id) , None )
531+ . ip_pools_fetch_default_for ( & opctx, Some ( silo_id) , None )
527532 . await
528533 . expect ( "Failed to get silo's default IP pool" ) ;
529534 assert_eq ! ( ip_pool. id( ) , fleet_default_pool. id( ) ) ;
@@ -543,7 +548,7 @@ mod test {
543548 // because that one was not a default, when we ask for silo default
544549 // pool, we still get the fleet default
545550 let ip_pool = datastore
546- . ip_pools_fetch_default_for ( & opctx, action , Some ( silo_id) , None )
551+ . ip_pools_fetch_default_for ( & opctx, Some ( silo_id) , None )
547552 . await
548553 . expect ( "Failed to get fleet default IP pool" ) ;
549554 assert_eq ! ( ip_pool. id( ) , fleet_default_pool. id( ) ) ;
@@ -559,14 +564,14 @@ mod test {
559564
560565 // now when we ask for the silo default pool, we get the one we just made
561566 let ip_pool = datastore
562- . ip_pools_fetch_default_for ( & opctx, action , Some ( silo_id) , None )
567+ . ip_pools_fetch_default_for ( & opctx, Some ( silo_id) , None )
563568 . await
564569 . expect ( "Failed to get silo's default IP pool" ) ;
565570 assert_eq ! ( ip_pool. name( ) . as_str( ) , "default-for-silo" ) ;
566571
567572 // and of course, if we ask for the fleet default again we still get that one
568573 let ip_pool = datastore
569- . ip_pools_fetch_default_for ( & opctx, action , None , None )
574+ . ip_pools_fetch_default_for ( & opctx, None , None )
570575 . await
571576 . expect ( "Failed to get fleet default IP pool" ) ;
572577 assert_eq ! ( ip_pool. id( ) , fleet_default_pool. id( ) ) ;
0 commit comments