Skip to content

Commit

Permalink
service IP pool lookup returns wrong authz error (#3933)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Aug 23, 2023
1 parent 05a9fa3 commit 0bc7bf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
11 changes: 1 addition & 10 deletions nexus/db-queries/src/db/datastore/ip_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,9 @@ impl DataStore {
) -> LookupResult<(authz::IpPool, IpPool)> {
use db::schema::ip_pool::dsl;

// Ensure the caller has the ability to look up these IP pools.
// If they don't, return "not found" instead of "forbidden".
opctx
.authorize(authz::Action::ListChildren, &authz::IP_POOL_LIST)
.await
.map_err(|e| match e {
Error::Forbidden => {
LookupType::ByCompositeId("Service IP Pool".to_string())
.into_not_found(ResourceType::IpPool)
}
_ => e,
})?;
.await?;

// Look up this IP pool by rack ID.
let (authz_pool, pool) = dsl::ip_pool
Expand Down
8 changes: 4 additions & 4 deletions nexus/tests/integration_tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ lazy_static! {
// IP Pool endpoint (Oxide services)
VerifyEndpoint {
url: &DEMO_IP_POOL_SERVICE_URL,
visibility: Visibility::Protected,
visibility: Visibility::Public,
unprivileged_access: UnprivilegedAccess::None,
allowed_methods: vec![
AllowedMethod::Get
Expand All @@ -812,7 +812,7 @@ lazy_static! {
// IP Pool ranges endpoint (Oxide services)
VerifyEndpoint {
url: &DEMO_IP_POOL_SERVICE_RANGES_URL,
visibility: Visibility::Protected,
visibility: Visibility::Public,
unprivileged_access: UnprivilegedAccess::None,
allowed_methods: vec![
AllowedMethod::Get
Expand All @@ -822,7 +822,7 @@ lazy_static! {
// IP Pool ranges/add endpoint (Oxide services)
VerifyEndpoint {
url: &DEMO_IP_POOL_SERVICE_RANGES_ADD_URL,
visibility: Visibility::Protected,
visibility: Visibility::Public,
unprivileged_access: UnprivilegedAccess::None,
allowed_methods: vec![
AllowedMethod::Post(
Expand All @@ -834,7 +834,7 @@ lazy_static! {
// IP Pool ranges/delete endpoint (Oxide services)
VerifyEndpoint {
url: &DEMO_IP_POOL_SERVICE_RANGES_DEL_URL,
visibility: Visibility::Protected,
visibility: Visibility::Public,
unprivileged_access: UnprivilegedAccess::None,
allowed_methods: vec![
AllowedMethod::Post(
Expand Down

0 comments on commit 0bc7bf0

Please sign in to comment.