Skip to content

authz: protect instance endpoints#673

Merged
davepacheco merged 7 commits into
mainfrom
authz-instance-endpoints
Feb 17, 2022
Merged

authz: protect instance endpoints#673
davepacheco merged 7 commits into
mainfrom
authz-instance-endpoints

Conversation

@davepacheco

@davepacheco davepacheco commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

This change adds protection for various Instance-related endpoints, following the same patterns as what's already been done for Disks and others. This one's a bit more involved because of the start/stop/reboot endpoints.

@davepacheco davepacheco mentioned this pull request Feb 7, 2022
71 tasks
Base automatically changed from authz-work to main February 8, 2022 21:57
@davepacheco davepacheco changed the title authz: protect instance endpoints (incomplete) authz: protect instance endpoints Feb 15, 2022
@davepacheco

Copy link
Copy Markdown
Collaborator Author

I think this is now ready for review.

@davepacheco davepacheco marked this pull request as ready for review February 15, 2022 23:48

pub fn project(&self) -> &Project {
&self.parent
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this used?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, here:

.vpc_fetch_by_name(&authz_instance.project().id(), vpc_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks. it didn't come up in my find because nexus.rs was collapsed

.await
.unwrap()
.parsed_body()
.unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see an obvious way around it besides adding yet another helper, but these chains are long and there are a lot of them

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree -- and a little error prone. (It's easy to forget the authn_as() and get a 404 for the wrong reason.) And you probably remember that the reason we got here was we had like 5-10 helper functions that were all only slightly different from each other :-/

It's possible most of our tests should be using clients generated from the OpenAPI spec. That could make a lot of these a lot clearer.

I've also been considering using something like hurl for our tests, where we use something like a DSL to describe the requests we want to make and the expected responses. This sounds fantastic at first but it gets hairy when you add authn and stuff like the side-door operations used by the tests to manipulate Nexus state outside the API.

@david-crespo david-crespo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@davepacheco davepacheco merged commit b3d2541 into main Feb 17, 2022
@davepacheco davepacheco deleted the authz-instance-endpoints branch February 17, 2022 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants