-
Notifications
You must be signed in to change notification settings - Fork 97
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
fix authentication for ECR #159
Conversation
I don't understand, did something change on the ECR side? It used to work fine.
|
Sorry for latency, traveling at the moment. No, nothing changed. 'aws ecr get-login-password' is a base64-encoded password token, and 'aws ecr get-authorization-token' is a bas64-encoded user:pass basic auth token (where pass is the same as get-login-password output). As enroot is using the v2 api and curl'ing, we need the auth token, vs just the login password. Docker login uses the password alone. Hope that makes sense, happy to discuss further or clarify. |
Oh actually, if curl is using --user that should work... maybe that's what changed at some point. I'll look at this in a bit. |
So the way the script works now, the change in this PR gets the right token. To use get-login-password, curl would have to change to using --basic and --user AWS:${pw}. So, I think this is correct, let me know what you think. |
The script is already using basic auth either with Line 63 in a648e76
This used to work so it's probably a change in the URL(s) we need to use. |
Sorry for latency in responses, had some travel. I can say that the endpoints or auth model haven't changed in ECR, so I don't think we need to trace things. I think we have two options based around using either a login password, or an auth token. Also, I could be misunderstanding the scripts :) In In our case, since we've set up the credentials file, we go down the netrc path, and our req_params end up being something like: We eventually we put the response from netrc file (read as We could alternatively change this to setting
Where I'm happy to go in either direction with this. Either way it seems to be a special case, because we don't expose a registry-wide auth endpoint (because access policies are repo-scoped in ECR). Let me know what you think, or if I've misunderstood along the way. Thanks! |
In the case of ECR, IIRC there are no bearer tokens, every call requires basic auth. Line 77 in a648e76
You should be able to check what's going on by adding With |
Signed-off-by: Jesse Butler <[email protected]>
I didn't intend to work around the existing flow, just to get the right sort of token in hand for injecting into a request header. However, given your response it made me think that it should work w/ login (as it'll have the user prepended, then encoded). I traced the curl that was failing (line 76), and the response body was clobbering into the auth token string in the header:
Not sure why we're just seeing this recently, or maybe only with ECR? Regardless, I think adding Like I said, I'm not a curl expert. There might be a better way to do this, but it does the trick. |
Ok yeah this makes more sense. Thanks for looking into it! |
Cool, thanks for going on the journey with me! |
Hi, sorry to re-ping that. |
Um yeah, also after checking |
Not a curl wizzard, tho… |
Fixes #143
It's a bit gross, but auth token needs to be retrieved using IAM credentials. Once retrieved, can be used with v2 OCI API.
This is the solution from the temp patch referred to in #59 but the final fix merged in looks like it tried to adopt using the get-login-password response.
Let me know what you think, sorry it took a while to come help out.