feat(install): Improve authentication handling and credential masking #4948
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR improves security and authentication in the install scripts by adding two main features:
1. Support for
.netrcauthenticationThe install scripts now automatically detect and use
.netrcfiles for authenticated downloads. This means you can keep your credentials in~/.netrc(the standard location) or specify a custom path with theNETRCenvironment variable. Bothcurlandwgetwill use these credentials when downloading Pixi.2. Credential masking in output
If you're using authenticated URLs (via
PIXI_DOWNLOAD_URL), the username and password won't be printed to the terminal anymore. We replace anyusername:password@patterns with***:***@in all log messages and errors.Why this matters:
Before these changes, if you provided a download URL with embedded credentials, they'd show up in plain text in your terminal and logs. This was especially problematic in CI/CD pipelines or when sharing logs publicly. Now your credentials stay hidden, and you have a cleaner way to provide them using
.netrcfiles.Fixes #4947
How Has This Been Tested?
TEST: How is a HTTP 401 handled?
I updated the HTTP_CODE to be 401 manually and ran the script. You will see in the output that it stopped and printed the desired message.TEST: ~/.netrc exists
I touched a blank .netrc and as you see in the script debug output the --netrc option is seen being used in the curl command.TEST: NETRC=$(pwd)/.netrc
I touched a blank .netrc file in the root of the repository and ran the script. The debug output shows that the curl command is using the --netrc-file option with the path to the .netrc file.Checklist:
schema/model.py.