pluggable credentials providers
Summary
git has credential.helper, kubectl can get credentials from executing a command.
uv can get credentials from keyring via
[tool.uv]
keyring-provider = "subprocess" but this does not allow to specify which command to use. Also it poses a chicken-and-egg problem when keyring is just made a dev dependency.
It would be great if in pyproject.toml one could define a command to execute to get tokens, similar to how kubectl config works, e.g.
[[tool.uv.index]]
url = "https://domain-account.d.codeartifact.region.amazonaws.com/pypi/domain/simple/"
credentials-provider = "aws codeartifact get-authorization-token --domain ... --domain-owner ... --query authorizationToken --output text --no-cli-pager"Optionally it would be great if tokens could be cached, e.g.
[[tool.uv.index]]
url = "https://domain-account.d.codeartifact.region.amazonaws.com/pypi/domain/simple/"
credentials-provider = "aws codeartifact get-authorization-token --domain ... --domain-owner ... --query authorizationToken --output text --no-cli-pager"
credentials-expire-seconds = 43200This is how .kube/config does it:
kind: Config
users:
- name: ...
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: aws
args: ["eks", "get-token", "--output", "json", "--cluster-name", "...", "--region", "..."]Example
Currently we work around by sourcing a uv-config.source-me which sets environment variables. uv in pycharm does not have access to these and so we have trouble syncing from pycharm.
If pyproject.toml could direct uv how to get credentials, all of these problems would go away, as uv would know how to retrieve credentials itself.
A dynamic, pluggable credential helper can be a script shipped with the repository, or an invocation of an existing cloud cli (like aws codeartifact ...).
Source: astral-sh/uv