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

libimage: search: add IdentityToken option for authentication #1328

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

sstosh
Copy link
Contributor

@sstosh sstosh commented Feb 15, 2023

IdentityToken will be needed if we use the search command
with authfile option.

Signed-off-by: Toshiki Sonoda sonoda.toshiki@fujitsu.com

IdentityToken will be needed if we use the search command
with authfile option.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
@rhatdan
Copy link
Member

rhatdan commented Feb 16, 2023

LGTM
@vrothberg @mtrmac PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vrothberg
Copy link
Member

@sstosh are you using libimage in another project?

@openshift-merge-robot openshift-merge-robot merged commit dbef45f into containers:main Feb 16, 2023
@sstosh
Copy link
Contributor Author

sstosh commented Feb 16, 2023

@sstosh are you using libimage in another project?

@vrothberg
I only use libimage for podman.
This PR is related to containers/podman#17463.

@sstosh sstosh deleted the search-token branch February 16, 2023 10:04
@@ -65,6 +65,9 @@ type SearchOptions struct {
// "username[:password]". Cannot be used in combination with
// Username/Password.
Credentials string
// IdentityToken is used to authenticate the user and get
// an access token for the registry.
IdentityToken string `json:"identitytoken,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the JSON annotation there? I wouldn’t expect libimage structs to be passed across processes or RPCs.

sys.DockerAuthConfig = authConf
// We should set the authConf unless a token was set. That's especially
// useful for Podman's remote API.
if options.IdentityToken != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Doesn’t this completely break uses of non-IdentityToken credentials?
  • I don’t understand what this condition is trying to express at all, and how it relates to the comment. If a token was set, we AFAICS need to set authConf as well, as this code does — but the comment says it doesn’t.
  • I also don’t understand how, if at all, it relates to the remote API; AFAICS remote/local should make no difference to the general structure of this code.
  • I think it would be more reliable for callers, and also allow a clearer expression of this code, if the code enforced that only one source of credentials were used.
numCredsSources := 0
if options.Username != "" { numCredsSources++; … }
if options.Credentials != "" { numCredsSources++; … }
if options.IdentityToken != "" { numCredsSources++; … }
if numCredsSources > 1 { /* error */ }
// possibly decide based on numCredsSources != 0

Copy link
Contributor Author

@sstosh sstosh Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this completely break uses of non-IdentityToken credentials?

Thank you for your reply.
I verified that search with AuthFilePath option is failed when we use of non-IdentityToken credentials.
I'll fix it to use getDockerAuthConfig() such as Pull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants