Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authz: protect instance endpoints #673

Merged
merged 7 commits into from
Feb 17, 2022
Merged

Conversation

davepacheco
Copy link
Collaborator

@davepacheco davepacheco commented Feb 7, 2022

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
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
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
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
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
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
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.

Copy link
Contributor

@david-crespo david-crespo left a comment

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