Skip to content

Add support for registry v3 JWK thumbprint key ID format#401

Merged
techknowlogick merged 1 commit intocesanta:mainfrom
evanebb:main
May 15, 2025
Merged

Add support for registry v3 JWK thumbprint key ID format#401
techknowlogick merged 1 commit intocesanta:mainfrom
evanebb:main

Conversation

@evanebb
Copy link
Contributor

@evanebb evanebb commented Feb 13, 2025

Fixes #386.
This is a fairly quick and dirty fix, feel free to burn this PR down :)

As mentioned in that issue, the v3 version of the registry no longer supports libtrust key IDs. There are multiple alternative options to choose from, but the simplest one to implement for this project is using the JWK thumbprint of the public key as the key ID instead.

For every certificate present in the rootcertbundle passed to the registry, it'll add the public key to the trusted keys identified by the JWK thumbprint: https://github.com/distribution/distribution/blob/63d3892315c817c931b88779399a8e9142899a8e/registry/auth/token/accesscontroller.go#L346-L348
So, if you pass this JWK thumbprint in the key ID header in the token, the registry can select the proper signing key using this thumbprint.

This PR allows configuring this through a new directive in the configuration file, namely token.disable_legacy_key_id.
If set to true, it will pass the JWK thumbprint in the key ID header instead of the libtrust key ID. It defaults to false for now, to avoid accidental breakage when updating setups using the v2 registry.

@choopm
Copy link

choopm commented May 15, 2025

Thanks @evanebb for providing this PR.

I can confirm this fixes the issues when upgrading from registry:2 to registry:3
by using the new config option token.disable_legacy_key_id: true.

@cesanta do you want to take a look at this PR please?


Until this gets merged, one might use the image I built which includes this change:

docker pull ghcr.io/choopm/docker_auth
# or
docker pull ghcr.io/choopm/docker_auth:1.13.0-1-g914f526

https://github.com/users/choopm/packages/container/package/docker_auth

@techknowlogick techknowlogick merged commit 25bdefb into cesanta:main May 15, 2025
4 checks passed
RaveNoX pushed a commit to deckhouse/3p-docker_auth that referenced this pull request Aug 27, 2025
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.

docker-registry has changed its JWT implementation, no longer supports libtrust key IDs

3 participants