-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Tekton on OpenShift: authentication issue with internal OpenShift registry #2258
Comments
The issue is migrated from #2074. Some highlights:
|
Here is the stack trace generated including the HTTP requests : https://gist.github.com/cmoulliard/2a0edd9f2e6e1f3b28539539021e2426 |
It looks like that we got an access_token : https://gist.github.com/cmoulliard/2a0edd9f2e6e1f3b28539539021e2426#file-gistfile1-txt-L772-L795 |
FYI. The file containing the credentials to log on to the docker registry is well present /builder/home/.docker/config.json
|
I added a comment to the gist to also log the auth part. The access token generated is well used several times but when we want to perform a post, then that fails
|
Problem resolved. We need a different role to be able to push to the internal docker registry : https://gist.github.com/cmoulliard/4dc5ad76ef7bf694f70c4e73262e7237 |
Nevertheless, the error reported |
@cmoulliard shouldn't the built-in |
@adambkaplan
|
@cmoulliard thank you very much for the investigation! Now it's clear what's going on. We can certainly work together to improve this situation. You are right that Jib has successfully authenticated with the registry to get a bearer token for the target repository (
Note Jib requested both pull and push scopes for the repository
However, my guess is that the registry decided to grant only the pull scope and not push (probably because your account lacked a push role). The returned And I think it is not wrong that an auth server returns "200 OK" when the returned token doesn't include all the requested scopes, according to the Docker authentication spec:
If my guess is correct, then I think the registry isn't at fault at this point. Then, it is very much expected that a push request (
But in this case, the registry returned 401 saying "authentication required", and that is confusing, because the user already authenticated with the registry. The registry already knows who the user is.
But I admit Jib should be fully prepared to handle this case intelligently and provide a more helpful error message. I haven't really thought about this scenario; it's insightful. |
One more question: When Jib first tried to access the integrated registry, it asked Jib to perform bearer token auth:
However, when the returned token didn't have push scope, it asked for basic auth:
Is this intended? Does the registry support both basic and bearer auth? It doesn't matter which auth is used? |
fyi @dmage |
@dmage Could you please help us here ? |
The integrated image registry supports both methods, but perhaps we should be consistent and use only Bearer in our errors. |
About
|
That's fair. Jib should be smarter to handle this case for better usability anyway. |
@adambkaplan @dmage I'm experimenting another problem using a use case similar but now JIB gets an Anonymous Bearer - https://gist.github.com/cmoulliard/10fd94f3509d02af6a16abd3d2b32ce8#file-gistfile1-txt-L575 Do you know why we get such response ? @chanseokoh JIB of course will reports this message which is also weird
The docker registry complaints about a RBAC issue
while the ServiceAccount mounted to the pod is linked to the role
and
|
Returning a plain string as a token doesn't look conventional, but it may be OK. Usually a bearer token is a JWT token as explain in https://jwt.io/introduction/. For example, if I decode your token from your previous Jib log, I see something like {
"jti": "50dfb273-baac-4359-b934-0d3151d07414",
"exp": 1580365099,
"nbf": 1580364799,
"iat": 1580364799,
"iss": "https://sso.redhat.com/auth/realms/rhcc",
"aud": "docker-registry",
"sub": "rh-gs-cmoullia",
"typ": "Bearer",
"azp": "docker-registry",
"access": []
} However, I think it is not a big deal if the auth server or the registry decided to return some arbitrary free-form string as long as they will handle such a string in their own way by design. Returning the string
Jib didn't pass any credentials (username and password). If Jib were able to retrieve any credentials for the registry, it could have sent the username and password pair through the
There was no
|
The dockercfg file has been mounted to the pod as it is available here
and JIB is configured as such
Do I miss something @chanseokoh ? |
Interesting. We look for @cmoulliard do you have |
only |
Just to clarify the current Jib behavior: if the registry initially requested bearer auth and the bearer auth succeeded, Jib assumes that the registry is set up to require bearer auth and not basic auth. However, as explained in #2258 (comment), the registry unusually asks for basic auth later. This inconsistency is a bit unusual given that Jib successfully completed the bearer auth before, so the current Jib code errors out. I guess this registry inconsistency is an oversight when implementing the bearer auth in the integrated registry (which I believe is based on the Docker Distribution). |
@cmoulliard we've released Jib 2.1.0 with this fix. You should no longer see the error about |
From #2074 (comment)
The text was updated successfully, but these errors were encountered: