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

Switch to use AWS signature v4 #1496

Closed
wants to merge 10 commits into from

Conversation

cswindle
Copy link

The main changes in the PR are to add support for AWS signature v4 (rather than the deprecated v2) to fix #1486. It also includes the following minor changes that I made to make it easier to validate the fix:

  • allow git authentication using SSH keys
  • fix docker-compose commands

@carols10cents
Copy link
Member

It looks like the tests need to be updated too. Do you need any help with that?

@cswindle
Copy link
Author

Sorry this was stuck behind a few other changes that I wanted to get into cargo, hopefully shouldn't take too much to get the tests passing, so I will sort them out.

Copy link
Member

@jtgeibel jtgeibel left a comment

Choose a reason for hiding this comment

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

@cswindle based on the tests that are failing, I think you're running into some issues with the http-data recording proxy used by the test code. You'll want to merge in master again as I recently landed some changes to the JSON output that will help here.

Once you have the proxy wired in, you'll need to record updated test data. I think that will go something roughly like:

  • Delete the files in src/tests/http-data that are related to your failing tests. I think the recording only happens if the file doesn't yet exist. Some of these test against the GitHub API, so don't delete more than you need to. Unfortunately, it looks like you have a few tests that sound like they do interact with GitHub: owners::new_crate_owner, team::publish_owned, team::remove_team_as_team_owner.
  • Set up your environment variables to point to a bucket that the tests can run against as they are recorded.
  • Run RECORD=1 cargo test
  • You should now have files for ALL the tests. A lot of them will just contain []. You can ignore the files that show up as new in git status, and just pay attention to the ones that show as modified.
  • If the diff looks good, you can run cargo test to verify that the tests work with the newly recorded data.

I hope that helps with getting the test green.

let path = Uploader::crate_path(crate_name, version);
Some(format!("https://{}/{}", host, path))
Some(format!("https://{}/{}/{}", host, bucket, path))
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this would change the location of where crates are stored in production. If this is necessary, it will need to be configurable.

};
let path = Uploader::readme_path(crate_name, version);
Some(format!("https://{}/{}", host, path))
Some(format!("https://{}/{}/{}", host, bucket, path))
Copy link
Member

Choose a reason for hiding this comment

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

Same here for the readme path

@@ -148,7 +183,7 @@ impl Uploader {
let mut body = Vec::new();
LimitErrorReader::new(req.body(), maximums.max_upload_size).read_to_end(&mut body)?;
verify_tarball(krate, vers, &body, maximums.max_unpack_size)?;
self.upload(&app.http_client()?, &path, body, "application/x-tar")?
self.upload(&path, body, "application/x-tar")?
Copy link
Member

Choose a reason for hiding this comment

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

The removed call to app.http_client() is part of the test infrastructure to record and play back HTTP requests. It looks like upload needs to add the proxy information as part of building the PutObjectRequest.

let req = DeleteObjectRequest {
bucket: bucket.to_string(),
key: path.to_string(),
..Default::default()
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, this needs to go through the proxy when testing.

@cswindle
Copy link
Author

Thanks for the pointers @jtgeibel, I have now managed to get one of the tests working by using record, so should be able to start making progress on this again.

@sgrif
Copy link
Contributor

sgrif commented Jan 26, 2019

@cswindle Are you still interested in working on this?

@sgrif
Copy link
Contributor

sgrif commented Jan 26, 2019

This is blocked on #1607

@sgrif sgrif added the blocked label Jan 26, 2019
@cswindle
Copy link
Author

@sgrif, we are currently running with a fork of crates.io to run internally as a private registry at work, so I am keen to gradually get all the changes merged back into crates.io codebase (which this is the first of a few changes), however I have been very busy with work, so not had any opportunity to get this work done. Likely be at least a month before I even think about picking this up again.

@sgrif
Copy link
Contributor

sgrif commented Jan 26, 2019

@cswindle Thanks for the update. Are you ok with closing this PR until you're more able to work on it?

@carols10cents
Copy link
Member

I'm going to close this PR for now; please feel free to reopen when you have time to work on this again @cswindle!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crates.io uses deprecated AWS signature v2 for S3 upload
4 participants