service IP pool lookup returns wrong authz error #3933
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed this while reading code debugging #3889. Basically, it's a wrong pattern to
map_err()
the result ofauthorize()
to replace aForbidden
error with aNotFound
. Distinguishing between these two is the responsibility of the authz subsystem because it should be consistent for all callers ofauthorize()
. If we want it to be a NotFound, the authz subsystem supports that via the impl ofAuthorizedResource::on_unauthorized()
for the resource. Concretely, we could preserve the existing behavior (while still delegating it to the authz subsystem) by customizing the impl forIpPoolList
:omicron/nexus/db-queries/src/authz/api_resources.rs
Lines 433 to 441 in 94cde6d
to look more like the one for most non-synthetic resources (which do return NotFound when someone's not authorized to read them):
omicron/nexus/db-queries/src/authz/api_resources.rs
Lines 132 to 154 in 94cde6d
I started looking at that when I saw that we're doing a
ListChildren
here, not aRead
. The resource itself ("the list of service IP pools") is not really hidden from end users -- the URL is even published in the OpenAPI spec. So I think it makes more sense to return Forbidden here, just like if you try to list IP pools when not authorized to do so.