Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Self Hosted Token authentication #261

Open
paulwilljones opened this issue Aug 29, 2024 · 0 comments · May be fixed by #262
Open

[BUG] Self Hosted Token authentication #261

paulwilljones opened this issue Aug 29, 2024 · 0 comments · May be fixed by #262
Assignees
Labels
bug Something isn't working

Comments

@paulwilljones
Copy link
Contributor

Describe the bug
When using a self hosted registry, credentials are provided which are used to retrieve a token. If the registry does not implement a token service, the endpoint returns a 404 and version-checker cannot authenticate to the registry.

$ k plogs -n version-checker -p version-checker-7db59c4996-8hj99 -c version-checker
...
error: failed to setup image registry clients: failed to create selfhosted client "http://docker-registry.registry.svc.cluster.local:5000": failed to setup token auth (404): 404 page not found
$ curl -i http://XXXXXX:XXXXXX@localhost:30000/v2/_catalog
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Thu, 29 Aug 2024 08:32:30 GMT
Content-Length: 37

{"repositories":["my-app"]}
$ curl -i http://XXXXXX:XXXXXX@localhost:30000/v2/token
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Thu, 29 Aug 2024 08:33:26 GMT
Content-Length: 19

404 page not found

This could be an edge case, and there should be a token endpoint in which case a 404 is the right response and basic auth shouldn't be used.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy registry to kind
  2. Deploy version-checker with selfhosted values:
...
selfhosted:
  - name: registry
    host: http://docker-registry.registry.svc.cluster.local:5000
    username: XXXXXX
    password: XXXXXX
  1. Push an image into registry using kaniko
  2. Create docker-registry secret and deploy image from local registry
apiVersion: v1
kind: Pod
metadata:
  annotations:
    enable.version-checker.io/test: "true"
  name: image-from-reg
  ...
spec:
  containers:
  - image: docker-registry.registry.svc.cluster.local:5000/my-app:0.0.1
...

Expected behavior
Basic auth should be used when token endpoint returns 404 so version-checker can authenticate with the registry.

Environment (please complete the following information):

  • Version-Checker: 0.7.0
  • kind 0.23.0
  • registry 2.8.1
@paulwilljones paulwilljones added the bug Something isn't working label Aug 29, 2024
@paulwilljones paulwilljones linked a pull request Aug 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants