Skip to content

Conversation

@jakeswenson
Copy link
Contributor

This PR adds explicit denial of API token authentication on most GET APIs.
Currently, CloudFront was never passing along the Authorization header for GET requests.
(See rust-lang/simpleinfra#43 for more details.)

In addressing that issue it was pointed out that there may be GET APIs that the team might not want to commit to allowing API tokens access to.

This PR attempts to limit the exposed APIs to:

  • /api/v1/crates?following=1 (the crates "search" API, which is the only way to get the list of crates a user is following.)
  • /api/v1/me

    Note: There were already tests verifying token access to this API, but with the CloudFront issue this API was not actually accessible.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @carols10cents (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@jakeswenson
Copy link
Contributor Author

r? @jtgeibel @pietroalbini

Also, I would like to call out that since the tests do not match the structure of the code is was painful to find existing tests and where to add new tests to.

@jakeswenson jakeswenson force-pushed the restrict-api-token-access-on-GET-requests branch from 31c4d05 to 64a326e Compare March 27, 2021 18:36
@pietroalbini
Copy link
Member

We discussed this in the weekly meeting, and agreed to allow authenticated requests on the two endpoints you allowed in this PR! Someone will review the actual implementation soon :)

@bors
Copy link
Contributor

bors commented Apr 6, 2021

☔ The latest upstream changes (presumably #3403) made this pull request unmergeable. Please resolve the merge conflicts.

@jakeswenson jakeswenson force-pushed the restrict-api-token-access-on-GET-requests branch from 64a326e to 0dc2c42 Compare April 6, 2021 14:32
@jakeswenson jakeswenson force-pushed the restrict-api-token-access-on-GET-requests branch from 0dc2c42 to 894460f Compare April 6, 2021 14:35
@pietroalbini
Copy link
Member

Thanks for the PR!

@bors r+

@bors
Copy link
Contributor

bors commented Apr 12, 2021

📌 Commit 894460f has been approved by pietroalbini

@bors
Copy link
Contributor

bors commented Apr 12, 2021

⌛ Testing commit 894460f with merge 66095dc...

@bors
Copy link
Contributor

bors commented Apr 12, 2021

☀️ Test successful - checks-actions
Approved by: pietroalbini
Pushing 66095dc to master...

@bors bors merged commit 66095dc into rust-lang:master Apr 12, 2021
@jakeswenson jakeswenson deleted the restrict-api-token-access-on-GET-requests branch April 12, 2021 14:44
bors added a commit that referenced this pull request Apr 14, 2021
Forbid token auth on `/me` endpoint

This prohibits access to the `/api/v1/me` endpoint via an API token. I'd like to merge and deploy this before moving forward on rust-lang/simpleinfra#43, which would expose this endpoint. (Previous lockdown work was done in #3470.)

The second commit ensure that the user is only authenticated on the search endpoint when querying for followed crates.

r? `@pietroalbini`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants