Commit Graph

1438 Commits

Author SHA1 Message Date
Youfu Zhang
4aab88fede fix: implement JWK thumbprint for Ed25519 public keys
Signed-off-by: Youfu Zhang <zhangyoufu@gmail.com>
2025-04-23 13:30:18 +08:00
closeobserve
a6ce1a7995 chore: make function comment match function name
Signed-off-by: closeobserve <pingcap@yahoo.com>
2025-04-13 17:40:27 +08:00
Lucas Melchior
ea6ab3652c fix newClient in azure storage provider
it can now return a client using default azure credentials
updated docs to include information on Azure Workload Identity

Signed-off-by: Lucas Melchior <lucasmelchior@flywheel.io>

fix anchor link in docs

Signed-off-by: Lucas Melchior <lucasmelchior@flywheel.io>
2025-04-08 10:22:34 -05:00
Milos Gajdos
ebd20d3be7
Azure driver retry fix (#4576) 2025-03-14 10:20:25 -07:00
Milos Gajdos
2ffa1171c2
Azure driver fix
* Make copy poll max retry, a global driver max retry
* Get support for etags in Azure
* Fix storage driver tests
* Fix auth mess and update docs
* Refactor Azure client and enable Azure storage tests

We use Azurite for integration testing which requires TLS,
so we had to figure out how to skip TLS verification when running tests locally:
this required updating testsuites Driver and constructor due to TestRedirectURL
sending GET and HEAD requests to remote storage which in this case is Azurite.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-03-14 10:03:09 -07:00
Oleg Gnusarev
b30274f26c use cached blob statter in ManifestService if available
Signed-off-by: Oleg Gnusarev <ognusarev@mts.ru>
2025-03-11 19:41:25 +03:00
Milos Gajdos
7884c71297
Add code comment
Adding a code comment that explains setting MD5 Sum field.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-03-01 07:35:41 -08:00
Milos Gajdos
e20645c050
Enable MD5 check on GCS driver
Apparently you can upload 0-size content wihtout GCS reportin any errors
back to you.

This is something a lot of our users experienced and reported. See here
for at least one example:
github.com/distribution/distribution/issues/3018

This sets tbe MD5 sum on the uploaded content which should rectify
things according to the docs:
https://pkg.go.dev/cloud.google.com/go/storage#ObjectAttrs

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-28 07:20:48 -08:00
evanebb
64f780f6c5
Explicitly return zero value instead of partially filled struct
Signed-off-by: evanebb <git@evanus.nl>
2025-02-24 16:04:41 +01:00
evanebb
0762a1bb57
Fix error message for unsupported signing algorithm by not overriding var
Signed-off-by: evanebb <git@evanus.nl>
2025-02-23 22:17:17 +01:00
evanebb
70d99154ac
Fix signing algorithm configuration for token authentication
Signed-off-by: evanebb <git@evanus.nl>
2025-02-23 22:16:11 +01:00
Milos Gajdos
63d3892315
registry/storage: add option to quiet GC output. (#4560) 2025-02-13 07:37:00 -08:00
Milos Gajdos
6ed60b0f48
Apply suggestions from code review
Co-authored-by: Sebastiaan van Stijn <thaJeztah@users.noreply.github.com>
Signed-off-by: Milos Gajdos <milosgajdos83@gmail.com>
2025-02-06 17:43:28 +00:00
Milos Gajdos
53c382641c
Remove named returns and fix linting woes
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-05 21:26:23 -08:00
Rafael Fonseca
a032989bf9 registry/storage: add option to quiet GC output.
Consumers might not want GC output to be displayed (e.g, if you have
your own logging system).

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
2025-02-02 10:18:45 +01:00
Milos Gajdos
f4a500caf6
Fix registry token authentication bug
When a JWT contains a JWK header without a certificate chain,
the original code only checked if the KeyID (kid) matches one of the trusted keys,
but doesn't verify that the actual key material matches.

As a result, if an attacker guesses the kid, they can inject an
untrusted key which would then be used to grant access to protected
data.

This fixes the issue such as only the trusted key is verified.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-01 15:30:18 -08:00
vitshev
328f802b8e
fix(configuration): replace string literals with constants
Signed-off-by: vitshev <vitshev@tracto.ai>
2024-12-16 20:43:30 +01:00
vitshev
916bdeae94
feat(configuration): support mtls auth mod
Signed-off-by: vitshev <vitshev@tracto.ai>
2024-12-16 20:43:20 +01:00
Milos Gajdos
f7236ab041
feat: support custom exec-based credential helper in proxy mode (#4438) 2024-11-05 11:48:33 +00:00
Thomas Way
5ee5aaa058
fix(registry/storage/driver/s3-aws): use a consistent multipart chunk size
Some S3 compatible object storage systems like R2 require that all
multipart chunks are the same size. This was mostly true before, except
the final chunk was larger than the requested chunk size which causes
uploads to fail.

In addition, the two byte slices have been replaced with a single
*bytes.Buffer and the surrounding code simplified significantly.

Fixes: #3873

Signed-off-by: Thomas Way <thomas@6f.io>
2024-10-30 21:46:36 +00:00
Milos Gajdos
bce9fcd135
avoid appending directory as file path in s3 driver Walk (#4485) 2024-10-16 21:14:56 +01:00
Flavian Missi
2e7482cb89 avoid appending directory as file path in s3 driver Walk
when a directory is empty, the s3 api lists it with a trailing slash.
this causes the path to be appended twice to the walkInfo slice, causing
purge uploads path transformations to panic when the `_uploads` is
emtpy.

this adds a check for file paths ending on slash, and do not append
those as regular files to the walkInfo slice.

fixes #4358

Signed-off-by: Flavian Missi <fmissi@redhat.com>
2024-10-14 14:53:31 +02:00
Flavian Missi
e44d9317d0 test s3 driver walk of empty dir
Signed-off-by: Flavian Missi <fmissi@redhat.com>
2024-10-14 14:53:26 +02:00
Pratik
5e59a64896 fix existing doc first
Signed-off-by: Pratik <pratikgparikh@gmail.com>
2024-10-08 22:06:38 +05:30
Sebastiaan van Stijn
0ab7f326e6
replace uses of Descriptor alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-07 13:07:47 +02:00
Milos Gajdos
44be16a883
TestProxyManifestsMetrics: use actual size of manifest (#4467) 2024-10-03 10:02:30 +01:00
Jose D. Gomez R
b53946ded3
fix: Add the token's rootcert public key to the list of known keys
- Add Unit tests for `token.newAccessController`
  + Implemented swappable implementations for `token.getRootCerts` and
    `getJwks` to unit test their behavior over the accessController
    struct.

- Use RFC7638 [0] mechanics to compute the KeyID of the rootcertbundle
  provided in the token auth config.

- Extends token authentication docs:
  + Extend `jwt.md` write up on JWT headers & JWT Validation
  + Updated old reference to a draft that's now RFC7515.
  + Extended the JWT validation steps with the JWT Header validation.
  + Reference `jwt.md` in `token.md`

[0]: https://datatracker.ietf.org/doc/html/rfc7638#autoid-13

Signed-off-by: Jose D. Gomez R <jose.gomez@suse.com>
2024-10-02 11:58:41 +02:00
Sebastiaan van Stijn
4a0e027e4d
TestProxyManifestsMetrics: use actual size of manifest
This test was using a hard-coded value for the size of the manifest,
which made it difficult to correlate the tested value with what it
was testing.

This patch updates populateRepo to return the actual size when
serialized, and updates manifestStoreTestEnv to include the
size to test for.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-18 22:10:15 +02:00
Milos Gajdos
a940e61623
Fix silly testing format mistakes
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-30 11:18:18 +01:00
Milos Gajdos
170ac07a5e
chore: bump golangci-lint and fix govert issues
The latest golangci-lint spits out some govet issues.
This commit fixes them. We are also bumping the linter version.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-30 10:28:24 +01:00
Chun-Hung Hsiao
eed9400d26
feat: support custom exec-based credential helper in proxy mode
This change allows users to run the registry as a pull-through cache
that can use a credential helper to authenticate against the upstream
registry.

Signed-off-by: Chun-Hung Hsiao <chhsiao@google.com>
2024-08-16 19:42:51 -07:00
Milos Gajdos
d8199f451b
chore: fix typo in rewrite storage middleware init
https://github.com/distribution/distribution/pull/4146 introduced a new
rewrite storage middleware but somehow missed to update the init logging
message. This commit fixes that.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-15 08:59:30 +01:00
Liang Zheng
db5c303e7e fix: skip removing layer's link file when '--dry-run' option spcified
Signed-off-by: Liang Zheng <zhengliang0901@gmail.com>
2024-07-31 23:21:45 +08:00
Milos Gajdos
f0bd0f6899
auth: fix token verification chain (#4415) 2024-07-29 18:56:44 +01:00
Milos Gajdos
70e0d8850c
auth: fix token verification chain
There was a small regression introduced in
https://github.com/distribution/distribution/pull/4349.

Specifically, if the certificate chain verification succeeds we should
return immediately instead of following up with further token verification
checks.

This commit fixes that: we only follow up with further token
verifications if x5c header is missing.

We've also refactored this method so it's hopefully clearer.

Co-authored-by: Kyle Squizzato <ksquizz@gmail.com>
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-07-29 18:48:09 +01:00
Milos Gajdos
91eda593ef
chore: fix typos returned in some errors
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-07-21 10:12:15 +01:00
Jan-Otto Kröpke
8619a11f73
fix nil pointer in s3 list api
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2024-07-19 15:12:54 +02:00
Milos Gajdos
252619876a
fix logic for handling regionEndpoint (#4341) 2024-07-18 22:56:58 +01:00
Sebastiaan van Stijn
1e89cf780c
deprecate Versioned in favor of oci.Versioned
Update the Manifest types to use the oci implementation of the Versioned
struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-18 18:38:32 +02:00
Milos Gajdos
a18cc8a656
S3 driver: Attempt HeadObject on Stat first, fail over to List
Stat always calls ListObjects when stat-ing S3 key.
Unfortauntely ListObjects is not a free call - both in terms of egress
and actual AWS costs (likely because of the egress).

This changes the behaviour of Stat such that we always attempt the
HeadObject call first and only ever fall through to ListObjects if the
HeadObject returns an AWS API error.

Note, that the official docs mention that the only error returned by
HEAD is NoSuchKey; experiments show that this is demonstrably wrong and
the AWS docs are simply outdated at the time of this commit.

HeadObject actually returns the following errors:
* NotFound: if the queried key does not exist
* NotFound: if the queried key contains subkeys i.e. it's a prefix
* BucketRegionError: if the bucket does not exist
* Forbidden: if Head operation is not allows via IAM/ACLs

Co-authored-by: Cory Snider <corhere@gmail.com>
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-07-17 10:16:54 +01:00
Cory Snider
671184e910
Remove ManifestBuilder interface
Defining an interface on the implementer side is generally not best
practice in Go code. There is no code in the distribution module which
consumes a ManifestBuilder value so there is no need to define the
interface in the distribution module. Export the concrete
ManifestBuilder types and modify the constructors to return concrete
values.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-16 11:16:06 +02:00
Sebastiaan van Stijn
9ba7340601
vendor: github.com/opencontainers/image-spec v1.1.0
full diff: https://github.com/opencontainers/image-spec/compare/v1.0.2...v1.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-10 14:58:09 -05:00
Milos Gajdos
4dd0ac977e
feat: implement 'rewrite' storage middleware (#4146) 2024-07-04 16:16:29 +01:00
Milos Gajdos
306f4ff71e
Replace custom Redis config struct with go-redis UniversalOptions (adds sentinel & cluster support) (#4306) 2024-07-04 16:00:37 +01:00
Andrey Smirnov
558ace1391
feat: implement 'rewrite' storage middleware
This allows to rewrite 'URLFor' of the storage driver to use a specific
host/trim the base path.

It is different from the 'redirect' middleware, as it still calls the
storage driver URLFor.

For example, with Azure storage provider, this allows to transform the
SAS Azure Blob Storage URL into the URL compatible with Azure Front
Door.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-07-04 18:49:25 +04:00
Liang Zheng
d9050bb917 remove layer's link file by gc
The garbage-collect should remove unsed layer link file

P.S. This was originally contributed by @m-masataka, now I would like to take over it.
Thanks @m-masataka efforts with PR https://github.com/distribution/distribution/pull/2288

Signed-off-by: Liang Zheng <zhengliang0901@gmail.com>
2024-07-03 00:16:11 +08:00
Milos Gajdos
a008d360b4
Create type alias for redis.UniversalOptions
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-06-30 11:20:51 +01:00
Milos Gajdos
f27799d1aa
Add custom TLS config to Redis
We also update the Redis TLS config initialization in the app.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-06-28 22:03:22 +01:00
Anders Ingemann
b63cbb3318
Replace custom Redis config struct with go-redis UniversalOptions
Huge help from @milosgajdos who figured out how to do the entire
marshalling/unmarshalling for the configs

Signed-off-by: Anders Ingemann <aim@orbit.online>
2024-06-14 10:31:09 +02:00
Milos Gajdos
675d7e27f5
feature: Bump go-jose and require signing algorithms in auth (#4349) 2024-05-30 20:54:20 +01:00