Skip to content

[FR]: Add authentication support to uv rules #721

@zsol

Description

@zsol

What is the current behavior?

Currently, authentication for external python packages discovered by uv is not supported.

Describe the feature

We should allow users to depend on packages that require authentication. These packages live on private registries, typically behind some kind of HTTP authentication - either using Basic auth or a Bearer token.
There are two main operations to authenticate: resolution, and archive fetching. Because resolution is entirely delegated to uv, and it contains a pretty robust credential management and authentication system, I propose we let the rules_py rely on the user configuring uv correctly, and then extracting necessary credentials from it at analysis time.

This would allow us to support not only static, long-lived credentials, but also passwords & tokens managed in the user's keyring, as well as short-lived JWTs used in services like pyx and Artifactory.

The way this could work at a high level is by:

  1. assuming the user has uv configured as normal according to the uv docs
  2. having the user declare their authenticated services via a new authenticate module tag
  3. at analysis time rules_py would run uv auth token $service for each configured service to extract (potentially short-lived) credentials
  4. these credentials would get passed down to the relevant http_file targets

If that all sounds good, I can take a stab at the implementation.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions