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

Add an authentication mode to [index] configuration #11600

Closed
zanieb opened this issue Feb 18, 2025 · 3 comments · Fixed by #11896
Closed

Add an authentication mode to [index] configuration #11600

zanieb opened this issue Feb 18, 2025 · 3 comments · Fixed by #11896
Assignees
Labels
enhancement New feature or improvement to existing functionality

Comments

@zanieb
Copy link
Member

zanieb commented Feb 18, 2025

Summary

There’s a bit of design work to be done here, but the rough problem is this:

  • If we receive a package index without a username, we always try an unauthenticated request first
  • If that fails, we search for credentials (e.g., via keyring)

However, some indexes don’t fail on unauthenticated requests, instead they just forward to the public PyPI and now the user is confused their package is missing. The current solution is to tell users to set a username in their index URL, as that will force us to fetch credentials. However, if the username varies per user (sometimes its just a constant), they can’t commit that to the pyproject.toml. So, the idea is: add an authentication “mode” to the tool.uv.index table which allows a user to explicitly say “never use authentication” or “always use authentication” for a given index.

See

Example

Not a final design, but for example

[[tool.uv.index]]
name = "foo"
url = "https://..."
authentication = "auto | always | never"
@zanieb zanieb added the enhancement New feature or improvement to existing functionality label Feb 18, 2025
@morotti
Copy link

morotti commented Feb 18, 2025

thanks, it would be great if it can be set with an environment variable, like UV_INDEX_AUTHENTICATION=always

@jdumas
Copy link

jdumas commented Feb 18, 2025

I wonder if a simple boolean force_auth = true would be sufficient? I don't see a case where the current auto mode would fail and you'd want to force unauthenticated instead.

In any case I'm eagerly awaiting for this option. This is currently a blocker for me to use uv in downstream applications for internal projects.

@zanieb
Copy link
Member Author

zanieb commented Feb 18, 2025

you'd want to force unauthenticated instead.

I was thinking of cases where you don't want to accidentally leak credentials to another index

@jtfmumm jtfmumm self-assigned this Feb 26, 2025
zanieb pushed a commit that referenced this issue Mar 10, 2025
Adds a new optional key `auth-policy` to `[tool.uv.index]` that sets the
authentication policy for the index URL.

The default is `"auto"`, which attempts to authenticate when necessary.
`"always"` always attempts to authenticate and fails if the endpoint is
unauthenticated. `"never"` never attempts to authenticate.

These policy address two kinds of cases:
* Some indexes don’t fail on unauthenticated requests; instead they just
forward to the public PyPI. This can leave the user confused as to why
their package is missing. The "always" policy prevents this.
* "never" allows users to ensure their credentials couldn't be leaked to
an unexpected index, though it will only allow for successful requests
on an index that doesn't require credentials.

Closes #11600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants