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

Retain authentication attached to URLs when making requests to the same host #1874

Merged
merged 6 commits into from
Feb 22, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 22, 2024

Closes #1860

In #1816, we started using the URL attached to a response instead of the request URL for subsequent requests — this fixes various bugs but has the side-effect of dropping credentials from the URL. Here, we transfer credentials from the request URL to the response URL. We perform RFC compliant checks for safety.

@zanieb zanieb added the bug Something isn't working label Feb 22, 2024
crates/uv-client/src/registry_client.rs Outdated Show resolved Hide resolved
Comment on lines 544 to 545
/// <https://datatracker.ietf.org/doc/html/rfc7235#section-2.2>
/// <https://datatracker.ietf.org/doc/html/rfc7230#section-5.5>
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for linking to the relevant sections

Comment on lines 569 to 571
if request_url.port() != response_url.port() {
if (request_url.port() == default_port || request_url.port().is_none())
&& (response_url.port() == default_port || response_url.port().is_none())
Copy link
Member

Choose a reason for hiding this comment

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

I find the check the port comment not that useful. I can see that we check something with the port but I'm having difficulty understanding what's being checked. Maybe we can explain that instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

This comment just matches all the previous ones saying which part we're checking, the inner comment is supposed to explain this. I can try to do better though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay 477e18b should be a lot better

crates/uv-client/src/registry_client.rs Outdated Show resolved Hide resolved
@zanieb
Copy link
Member Author

zanieb commented Feb 22, 2024

Fyi I tested this against AWS CodeArtifact.

@zanieb zanieb merged commit 86052fb into main Feb 22, 2024
7 checks passed
@zanieb zanieb deleted the zb/fix-auth branch February 22, 2024 17:56
zanieb added a commit that referenced this pull request Feb 23, 2024
…les (#1886)

Closes #1709
Closes #1371

Tested with the reproduction provided in #1709 which gets past the HTTP
401.

Reuses the same copying logic we introduced in
#1874 to ensure authentication is
attached to file URLs with a realm that matches that of the index. I had
to move the authentication logic into a new crate so it could be used in
`distribution-types`.

We will want to something more robust in the future, like track all
realms with authentication in a central store and perform lookups there.
That's what `pip` does and it allows consolidation of logic like netrc
lookups. That refactor feels significant though, and I'd like to get
this fixed ASAP so this is a minimal fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.1.7 broke AWS CodeArtifact
3 participants