Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Credential library support for legacy auth config keys #1

Closed
AaronFriel opened this issue Feb 4, 2023 · 8 comments
Closed

Credential library support for legacy auth config keys #1

AaronFriel opened this issue Feb 4, 2023 · 8 comments
Milestone

Comments

@AaronFriel
Copy link

AaronFriel commented Feb 4, 2023

Regarding the initiative to create a general authentication library for registries (thanks to @shizhMSFT in #413), I encountered some legacy behavior in the Docker credential helper libraries and thought it should be documented to ensure ORAS supports it in this new library.

Credential helpers may return keys either of the form, e.g., https://ghcr.io or ghcr.io, or the original Docker index server URL https://index.docker.io/v1/. See, Docker issue: docker/docker-credential-helpers#256

To handle this, libraries implementing auth and intending to choose an auth configuration must:

  1. Use a ToHostname routine to homogenize the input server name, removing the scheme and then path parts after the hostname. This function would take a name like https://ghcr.io/aaronfriel and return ghcr.io.

  2. First attempt a direct lookup in the map (authConfigs["ghcr.io"]), and early return on success. Otherwise, iterate over the map and perform the ToHostname conversion on each of the keys, returning the first key that equals the input ("ghcr.io" == ToHostname(key)).

Example: https://github.com/docker/cli/blob/v20.10.23/cli/config/credentials/file_store.go#L33-L47

@shizhMSFT shizhMSFT transferred this issue from oras-project/oras-go Feb 6, 2023
@shizhMSFT shizhMSFT added this to the v0.1.0 milestone Feb 6, 2023
@Wwwsylvia
Copy link
Member

Hi @AaronFriel, thanks for the information! Does this issue occur on both native store (desktop, pass, etc.) and config file store?

@AaronFriel
Copy link
Author

I think so @Wwwsylvia, but this is primarily an advisory issue that we'll need to handle entries with and without https:// prefixes. On macOS, it looks like the credential store preferentially returns the https:// prefix as of Feb 6, 2023.

@wangxiaoxuan273
Copy link
Collaborator

I think so @Wwwsylvia, but this is primarily an advisory issue that we'll need to handle entries with and without https:// prefixes. On macOS, it looks like the credential store preferentially returns the https:// prefix as of Feb 6, 2023.

I tested on my mac today, it still prefixes https://.
Screenshot 2023-04-16 at 13 42 36

@wangxiaoxuan273
Copy link
Collaborator

wangxiaoxuan273 commented Apr 20, 2023

I have tested with oras-credential-go, we don't need the https prefix to retrieve the credentials from OSX keychain. The current implementation of oras-credential-go works fine.

Screenshot 2023-04-17 at 12 01 10

@Wwwsylvia
Copy link
Member

I have tested with oras-credential-go, we don't need the https prefix to retrieve the credentials from OSX keychain. The current implementation of oras-credential-go works fine.

Screenshot 2023-04-17 at 12 01 10

Thanks @wangxiaoxuan273 for the testing!
It looks like adding https prefix is a osxkeychain-specific behaviour, and it has been handled by the docker-credential-helpers library so that we don't need to worry about that at the oras-credentials-go level.
For the https://index.docker.io/v1/ redirection, we support it in the Credential() function (See PR #45).

@shizhMSFT
Copy link
Contributor

Closing this issue as it is handled by the osxkeychain helper as mentioned by @wangxiaoxuan273 and @Wwwsylvia.

@Wwwsylvia
Copy link
Member

Wwwsylvia commented Oct 12, 2023

The issue still exists. See notaryproject/notation#801.

@Wwwsylvia Wwwsylvia reopened this Oct 12, 2023
Wwwsylvia added a commit that referenced this issue Oct 16, 2023
Backporting
[`e8e4f84`](oras-project/oras-go@e8e4f84)
from `oras-go`.

Fix: #1 
Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
@Wwwsylvia
Copy link
Member

Closing as #100 has been merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Status: No status
Development

No branches or pull requests

4 participants