-
Notifications
You must be signed in to change notification settings - Fork 94
Fix authentication for private ECR registry #727
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
base: main
Are you sure you want to change the base?
Conversation
thecoshman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look sensible to me, though as I'm not that familiar with js dev, what's the reason so much ended up needing to be marked as async here?
|
Thanks @thecoshman and sorry for the late reply. The alternative (what I did for a workaround at first), was to keep the generated token from authenticate() in Ecr.js inside a member property, and reuse it in the getPullAuth(). This was simpler to implement as only code changes in Ecr.js but, from my point of view, not really clean as it forces an hidden dependency between authenticate() and getPullAuth() methods, which is not really good pratices. If someone calls getPullAuth() before authenticate() in the future, it will fail; so that's why I moved to async in getPullAuth(). I'm not a javascript expert, but from what I've saw on various sources on internet, that's apparently the best practices for such cases. I would have prefered to avoid changing so much code but that's probably cleaner than my first workaround :) Code from workaround 1: async authenticate(image, requestOptions) {
// [...]
const authorizationToken = await ecr.getAuthorizationToken().promise();
const tokenValue = authorizationToken.authorizationData[0].authorizationToken;
requestOptionsWithAuth.headers.Authorization = `Basic ${tokenValue}`;
// CODE ADDED
const auth = Buffer.from(tokenValue, 'base64').toString().split(':');
this.pullAuth = {
username: auth[0],
password: auth[1],
};
// [...]
return requestOptionsWithAuth;
}
// Before
getAuthPull() {
return this.configuration.accesskeyid
? {
username: this.configuration.accesskeyid,
password: this.configuration.secretaccesskey,
}
: undefined;
}
// After
getAuthPull() {
return this.configuration.accesskeyid ? this.pullAuth : undefined;
} |
|
@scadorel oh that makes perfect sense. Thanks for the clear explanation - certainly helps me get to grips a bit more with js dev... I've been trying to avoid it, but it's caught up with me 😅 |
|
Hi, looks good, thank you. |
|
Hello, are we able to merge this in? I would love this feature because I have the same issue with ECR as well. |
96897e4 to
49b0b09
Compare
|
Hello @fmartinou, branch rebased and updated with latest changes from main. |
|
Hey, just to give you some feedback. I cloned your fork @fmartinou and built the Docker container to test it out. Everything works perfectly! Once this is merged in I can start using the public build of WUD again. |
Fixes issue #726.
This is my first PR on this repo, let me know if I need to change anything 👍