Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nexus/db-queries/src/policy_test/resource_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl_dyn_authorized_resource_for_resource!(authz::AffinityGroup);
impl_dyn_authorized_resource_for_resource!(authz::AntiAffinityGroup);
impl_dyn_authorized_resource_for_resource!(authz::Blueprint);
impl_dyn_authorized_resource_for_resource!(authz::Certificate);
impl_dyn_authorized_resource_for_resource!(authz::ConsoleSession);
impl_dyn_authorized_resource_for_resource!(authz::DeviceAccessToken);
impl_dyn_authorized_resource_for_resource!(authz::DeviceAuthRequest);
impl_dyn_authorized_resource_for_resource!(authz::Disk);
Expand All @@ -259,11 +260,13 @@ impl_dyn_authorized_resource_for_resource!(authz::InstanceNetworkInterface);
impl_dyn_authorized_resource_for_resource!(authz::InternetGateway);
impl_dyn_authorized_resource_for_resource!(authz::InternetGatewayIpAddress);
impl_dyn_authorized_resource_for_resource!(authz::InternetGatewayIpPool);
impl_dyn_authorized_resource_for_resource!(authz::IpPool);
impl_dyn_authorized_resource_for_resource!(authz::LoopbackAddress);
impl_dyn_authorized_resource_for_resource!(authz::Rack);
impl_dyn_authorized_resource_for_resource!(authz::PhysicalDisk);
impl_dyn_authorized_resource_for_resource!(authz::Project);
impl_dyn_authorized_resource_for_resource!(authz::ProjectImage);
impl_dyn_authorized_resource_for_resource!(authz::RouterRoute);
impl_dyn_authorized_resource_for_resource!(authz::SamlIdentityProvider);
impl_dyn_authorized_resource_for_resource!(authz::ScimClientBearerToken);
impl_dyn_authorized_resource_for_resource!(authz::Service);
Expand All @@ -279,7 +282,9 @@ impl_dyn_authorized_resource_for_resource!(authz::SupportBundle);
impl_dyn_authorized_resource_for_resource!(authz::TufArtifact);
impl_dyn_authorized_resource_for_resource!(authz::TufRepo);
impl_dyn_authorized_resource_for_resource!(authz::TufTrustRoot);
impl_dyn_authorized_resource_for_resource!(authz::UserBuiltin);
impl_dyn_authorized_resource_for_resource!(authz::Vpc);
impl_dyn_authorized_resource_for_resource!(authz::VpcRouter);
impl_dyn_authorized_resource_for_resource!(authz::VpcSubnet);
impl_dyn_authorized_resource_for_resource!(authz::Alert);
impl_dyn_authorized_resource_for_resource!(authz::AlertReceiver);
Expand Down
45 changes: 40 additions & 5 deletions nexus/db-queries/src/policy_test/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use super::resource_builder::ResourceSet;
use nexus_auth::authz;
use omicron_common::api::external::LookupType;
use omicron_uuid_kinds::AccessTokenKind;
use omicron_uuid_kinds::BuiltInUserKind;
use omicron_uuid_kinds::ConsoleSessionKind;
use omicron_uuid_kinds::GenericUuid;
use omicron_uuid_kinds::PhysicalDiskUuid;
use omicron_uuid_kinds::RackUuid;
Expand Down Expand Up @@ -205,6 +207,29 @@ pub async fn make_resources(
LookupType::by_id(subnet_pool_id),
));

let ip_pool_id = "f9bf2e93-1f3f-4f4e-9c0f-3c8f6a8d6f2a".parse().unwrap();
builder.new_resource(authz::IpPool::new(
authz::FLEET,
ip_pool_id,
LookupType::by_id(ip_pool_id),
));

let console_session_id: TypedUuid<ConsoleSessionKind> =
"a1b2c3d4-0000-4000-8000-000000000001".parse().unwrap();
builder.new_resource(authz::ConsoleSession::new(
authz::FLEET,
console_session_id,
LookupType::by_id(console_session_id),
));

let user_builtin_id: TypedUuid<BuiltInUserKind> =
"a1b2c3d4-0000-4000-8000-000000000002".parse().unwrap();
builder.new_resource(authz::UserBuiltin::new(
authz::FLEET,
user_builtin_id,
LookupType::by_id(user_builtin_id),
));

builder.build()
}

Expand Down Expand Up @@ -411,6 +436,19 @@ async fn make_project(
Uuid::new_v4(),
LookupType::ByName(format!("{}-subnet1", vpc1_name)),
));
let router_name = format!("{}-router1", vpc1_name);
let router = authz::VpcRouter::new(
vpc1.clone(),
Uuid::new_v4(),
LookupType::ByName(router_name.clone()),
);
builder.new_resource(router.clone());
// Test a resource nested three levels below Project
builder.new_resource(authz::RouterRoute::new(
router,
Uuid::new_v4(),
LookupType::ByName(format!("{}-route1", router_name)),
));

builder.new_resource(authz::Snapshot::new(
project.clone(),
Expand Down Expand Up @@ -522,11 +560,8 @@ pub fn exempted_authz_classes() -> BTreeSet<String> {
// need to call the macro `impl_dyn_authorized_resource_for_resource!`
// for the type you are implementing the test for. See
// resource_builder.rs for examples.
authz::IpPool::get_polar_class(),
authz::VpcRouter::get_polar_class(),
authz::RouterRoute::get_polar_class(),
authz::ConsoleSession::get_polar_class(),
authz::UserBuiltin::get_polar_class(),
//
// none yet.
]
.into_iter()
.map(|c| c.name)
Expand Down
153 changes: 153 additions & 0 deletions nexus/db-queries/tests/output/authz-roles.out
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,40 @@ resource: VpcSubnet "silo1-proj1-vpc1-subnet1"
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: VpcRouter "silo1-proj1-vpc1-router1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘

@david-crespo david-crespo Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewer and limited collaborator can't modify networking resources, as expected

silo1-proj1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-proj1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-proj1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: RouterRoute "silo1-proj1-vpc1-router1-route1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-proj1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-proj1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: Snapshot "silo1-proj1-disk1-snapshot1"

USER Q R LC RP M MP CC D
Expand Down Expand Up @@ -967,6 +1001,40 @@ resource: VpcSubnet "silo1-proj2-vpc1-subnet1"
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: VpcRouter "silo1-proj2-vpc1-router1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: RouterRoute "silo1-proj2-vpc1-router1-route1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-collaborator ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
silo1-limited-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: Snapshot "silo1-proj2-disk1-snapshot1"

USER Q R LC RP M MP CC D
Expand Down Expand Up @@ -1545,6 +1613,40 @@ resource: VpcSubnet "silo2-proj1-vpc1-subnet1"
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: VpcRouter "silo2-proj1-vpc1-router1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: RouterRoute "silo2-proj1-vpc1-router1-route1"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: Snapshot "silo2-proj1-disk1-snapshot1"

USER Q R LC RP M MP CC D
Expand Down Expand Up @@ -2038,6 +2140,57 @@ resource: SubnetPool id "e3a6e04e-ad41-483c-8ee9-3958c3ffb4e5"
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: IpPool id "f9bf2e93-1f3f-4f4e-9c0f-3c8f6a8d6f2a"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
fleet-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✔ ✘
fleet-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✔ ✘
silo1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✔ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anybody can create child because that's the perm we use to allocate IP addresses. It would be nice to have this only work for users in a silo linked to the pool, but currently this is enforced in app code.


resource: ConsoleSession id "a1b2c3d4-0000-4000-8000-000000000001"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
fleet-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

resource: UserBuiltin id "a1b2c3d4-0000-4000-8000-000000000002"

USER Q R LC RP M MP CC D
fleet-admin ✘ ✔ ✔ ✔ ✔ ✔ ✔ ✔
fleet-collaborator ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
fleet-viewer ✘ ✔ ✔ ✔ ✘ ✘ ✘ ✘
silo1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-admin ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-limited-collaborator ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
silo1-proj1-viewer ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘
unauthenticated ! ! ! ! ! ! ! !
scim ✘ ✘ ✘ ✘ ✘ ✘ ✘ ✘

ACTIONS:

Q = Query
Expand Down
Loading