Skip to content

feat: share project signing keys across sources - #620

Merged
eitsupi merged 4 commits into
feat/lockfile-forward-compatfrom
feat/project-signing-keys
Dec 1, 2026
Merged

eitsupi merged 4 commits into
feat/lockfile-forward-compatfrom
feat/project-signing-keys

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Prepare for HTTP URL template sources by sharing signing key definitions across project sources.

  • Policy lookup: Client.ProjectSigningPolicy(name) looks up a named definition in the project's [signing_keys] without reading the key file. A missing project definition returns an error, even if the user config defines the same name.
  • Shared keys: Project registries and other sources that use the same definition share the first certificate successfully read from its key file in a SigningOperation.
  • Registry overrides: WithBaseURL and WithRegistries (and DBC_BASE_URL in the CLI) still skip project registry entries. Project key definitions remain available, and an invalid definition now causes NewClient to fail even with an override. With DBC_BASE_URL set, dbc search, dbc info, and dbc docs still skip dbc.toml.

@eitsupi
eitsupi added this pull request to stack #619 November 25, 2026 23:21
@eitsupi eitsupi changed the title feat/project signing keys feat: share project signing keys across sources Nov 25, 2026
@eitsupi
eitsupi requested review from amoeba and zeroshade November 26, 2026 00:54
@eitsupi
eitsupi marked this pull request as ready for review November 26, 2026 00:54
@eitsupi
eitsupi removed this pull request from stack #619 November 26, 2026 05:44
@eitsupi
eitsupi added this pull request to stack #624 November 26, 2026 05:45

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Parsing the definitions once means the project's registries and other sources share one *signingKeyFile, so they share one cached key per SigningOperation. Always passing WithProjectConfig doesn't add any new CLI failure with DBC_BASE_URL, since decodeDriverList already validates the project config. The library behavior change is documented and only affects unreleased API. A few nits inline.

Comment thread client.go Outdated

// The project's signing key definitions also serve sources other than
// registries, so they are parsed even when the registries are replaced;
// its registry entries are only parsed when they are merged. Its

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this is true within NewClient, but LoadProjectConfig, Validate and the CLI's decodeDriverList still validate the registry entries up front, so DBC_BASE_URL doesn't get around a broken [[registries]] entry. Maybe "its registry entries are only merged when no override is given"?

Comment thread client.go
func (c *Client) ProjectSigningPolicy(name string) (SigningPolicy, error) {
policy, ok := c.projectSigning[name]
if !ok {
return SigningPolicy{}, fmt.Errorf("signing_key %q is not defined in [signing_keys] of the project", name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: when no WithProjectConfig was passed at all, this says the name isn't defined "of the project", which could mislead a library caller who forgot the option. Could that case get its own message, e.g. "no project configuration"?

Comment thread client.go
// The project's registries that name the same definition share the policy,
// so within one SigningOperation the first key read from that definition
// serves both.
func (c *Client) ProjectSigningPolicy(name string) (SigningPolicy, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nothing calls this yet within this PR; I assume #621 is the consumer. Fine as part of the stack, just noting it's public API, so if the HTTP source design changes shape it's worth revisiting before 0.4.0.

Client.ProjectSigningPolicy returns the policy of a [signing_keys]
definition of the project by name, for sources of dbc.toml other than
registries. It shares the policy with the project's registries that name
the same definition, so one SigningOperation reads its key file once for
both, and it never falls back to a definition of the global config. The
definitions are parsed also when WithBaseURL or WithRegistries replaces
the registries, and the CLI passes the project to the client under
DBC_BASE_URL as well, which still replaces its registries.
With WithBaseURL or WithRegistries the project's registry entries are
ignored, so an invalid one no longer stops NewClient; its signing key
definitions are still checked, since ProjectSigningPolicy uses them.
Also describe ProjectSigningPolicy's lookup without reading key files, and
drop the unused definitions from parseRegistryConfig.
…tion

Also say that the project's registry entries are only merged when no
override is given; they are still validated.
@eitsupi

eitsupi commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

acfcd98 clarifies when project registries are merged and gives a separate error when a key lookup has no project configuration.
#621 uses ProjectSigningPolicy for HTTP sources.

@eitsupi
eitsupi requested a review from zeroshade November 30, 2026 14:34

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed after acfcd98; still LGTM.

  • The comment in NewClient now says correctly when project registry entries are merged.
  • The separate error when no project configuration was given is clearer, and the new subtest covers it.
  • Good that #621 is the caller of ProjectSigningPolicy.

Optional nit: hasProject could be dropped. projectSigning is non-nil exactly when a project config was given, so c.projectSigning == nil would do the same check. Not blocking.

@eitsupi
eitsupi merged commit e76df6f into main Dec 1, 2026
34 of 35 checks passed
@eitsupi
eitsupi deleted the feat/project-signing-keys branch December 1, 2026 00:30
eitsupi added a commit that referenced this pull request Dec 1, 2026
Let projects install off-registry dbc packages using HTTP URL templates
in `dbc.toml` (see #394).

```toml
[drivers.example]
version = "1.2.0"

[drivers.example.source]
type = "http"
url = "https://example.com/releases/download/v{version}/example_{os}_{arch}_v{version}.tar.gz"
checksum_url = "https://example.com/releases/download/v{version}/SHA256SUMS"
signing_key = false
```

- **Configuration:** Requires a dbc package archive. URL templates
support `{version}`, `{os}`, and `{arch}` in the path. dbc does not
discover available versions, so `version` must be a full version
(`"1.2.0"` or `"=1.2.0"`); `{version}` expands to it, including any
prerelease or build metadata. Unknown HTTP source keys are errors. An
HTTP source can name a key from the project's `[signing_keys]` (#620),
use the built-in key by default, or opt out with `signing_key = false`.
Registry sources reject `signing_key` and `checksum_url`.
- **Targets:** Locks archives for the declared platforms, or the current
platform by default. **Limitation:** musl and architecture variant
drivers (such as `linux_amd64_musl` or `linux_amd64_v3`) cannot be
installed from an HTTP source yet. A template cannot tell those targets
from the plain target, so HTTP sources reject them, including artifacts
already recorded for them.
- **Hashes:** dbc reads new hashes from `checksum_url` when set, as GNU
`sha256sum` lines or as a single hash for a file that serves one
archive. Otherwise, it records the first download's SHA-256 and size. As
in #623, locking extracts an archive only to check an applicable v1
library checksum. At installation, `dbc sync` checks the archive, its
`MANIFEST` version, and any required library signature. dbc warns when a
new hash comes from a declared plain HTTP URL.
- **Downloads:** Archive and checksum requests carry no registry
credentials or telemetry IDs. URL replacements apply. The CLI rejects
HTTPS-to-HTTP replacements and redirects. `DBC_BASE_URL` does not affect
HTTP sources.
- **Lock replay:** Records the template digest and absolute archive
URLs. `dbc sync` rejects a changed source or a recorded URL that no
longer matches the template. `dbc lock` can relock an explicitly changed
source subject to signer continuity. Each unsigned source is a signer of
its own, so changing an unsigned source's template needs its lock entry
removed first; the error says so. Removing the HTTP declaration stops
both commands without a registry search.
- **`dbc sync --locked`:** Installs from the recorded artifacts without
updating the lockfile or fetching a checksum file or registry index. The
HTTP declaration, URL template, exact version, and pinned signer must
still match.
- **Future work:** mise's HTTP backend reads versions from a
`version_list_url`, extracting them with a regex, JSON path or
expression, so that `latest` and version prefixes work. A similar source
key would let an HTTP source take a version range; this version of dbc
rejects such a key with a hint that a newer dbc may be required.

This branch was previously deployed

1 inactive deployment
snapshot — acfcd98e Deployed Nov 30, 2026 by eitsupi via snapshot #1410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants