-
Notifications
You must be signed in to change notification settings - Fork 202
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
libimage: Fix getDockerAuthConfig() for authentication #1342
Conversation
Lines 241 to 245 in d6cedd5
Added in #1328. |
I'm waiting to pass the podman CI tests which include this commit. |
This is ready for review. |
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.
@mtrmac PTAL
libimage/search.go
Outdated
@@ -348,6 +331,41 @@ func searchRepositoryTags(ctx context.Context, sys *types.SystemContext, registr | |||
return paramsArr, nil | |||
} | |||
|
|||
// getDockerAuthConfig extracts a docker auth config from the CopyOptions. Returns | |||
// nil if no credentials are set. | |||
func (options *SearchOptions) getDockerAuthConfig() (*types.DockerAuthConfig, error) { |
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.
This is a code clone of https://github.com/containers/common/blob/main/libimage/copier.go#L172.
It.s probably worth refactoring the two functions into one that would username, credetials and ID token as arguments? The getDockerAuthConfig()
methods could call this function.
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.
Yes please.
32703e1
to
585e07e
Compare
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.
LGTM, thank you!
@mtrmac PTAL
The podman CI tests are passed and ready for review. |
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.
LGTM overall.
I think The (creds
+ passwd
) case is worth preventing, but I don’t feel strongly about it – others, feel free to merge as is.
libimage/copier.go
Outdated
} | ||
|
||
return nil, nil | ||
// Return nil if there is no credential source. | ||
if numCredsSources == 0 { |
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.
(Absolutely non-blocking: Alternatively, move the numCredsSources
checks before creating authConf
, so that we don’t create an authConf
with invalid data at all.
Then this can be
switch numCredsSources {
case 0: return nil, nil
case 1: return &types.DockerAuthConfig{…}, nil
default: /* error */
)
- We need to set DockerAuthConfig even if we use of non-IdentityToken credentials. - This function should be failed when there are multiple credential sources, not only `Username` + `Credentials`. Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Thank you for your review. I fixed it. |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mtrmac, sstosh, vrothberg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
We need to set DockerAuthConfig even if we use of
non-IdentityToken credentials.
This function should be failed when there are multiple
credential sources, not only
Username
+Credentials
.Signed-off-by: Toshiki Sonoda sonoda.toshiki@fujitsu.com