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

Apply from-URL credentials in authentication middleware #2449

Merged
merged 1 commit into from
Mar 15, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

Right now, the middleware doesn't apply credentials that were originally sourced from a URL. This requires that we call with_url_encoded_auth whenever we create a request to ensure that any credentials that were passed in as part of an index URL (for example) are respected.

This PR modifies uv-auth to instead apply those credentials in the middleware itself. This seems preferable to me. As far as I can tell, we can only add in-URL credentials to the store ourselves (since in-URL credentials are converted to headers by the time they reach the middleware). And if we ever didn't apply those credentials to new URLs, it'd be a bug in the logic that precedes the middleware (i.e., us forgetting to call with_url_encoded_auth).

Test Plan

cargo run pip install with an authenticated index.

@charliermarsh charliermarsh requested a review from zanieb March 14, 2024 03:57
} else {
// It's assumed that the base URL already contains any necessary credentials.
Copy link
Member Author

Choose a reason for hiding this comment

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

The real win here is we don't have to think about where / when all the auth is preserved. The middleware deals with it.

@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Mar 14, 2024
@zanieb zanieb enabled auto-merge (squash) March 15, 2024 16:12
@zanieb zanieb merged commit 8463d6d into main Mar 15, 2024
30 checks passed
@zanieb zanieb deleted the charlie/auth branch March 15, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal A refactor or improvement that is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants