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

[Feature] support notation login #218

Merged
merged 5 commits into from
Jul 20, 2022

Conversation

binbin-li
Copy link
Contributor

@binbin-li binbin-li commented Jun 30, 2022

What?

Add support for logging in/out. Related Issue: #119

Work need to be done:

  • Add new CMDs that supports login and logout.
  • For login CMD, validate the input credentials through ORAS, and store it in the credentials store.
  • For logout CMD, remove the credential from the credentials store
  • For other CMDs that need authentication, we should get the credentials saved in the credentials store.
  • Create a submodule that interacts with the credentials store and validate credentials via ORAS.
  • Integrate with the new Directory pkg to manipulate the config file once it's ready to be use
  • Add parser that parse the config.json into the required creds config(support configs for both docker and notation)

Test?

  • Manual test (done):

test plan:

  1. run login cmd
  2. run logout cmd
  3. run other CMDs, e.g. list/push/pull
    3.1 user types username/password explicitly. [expect: user-typed credential is used]
    3.2 user doesn't type username/password. [expect: saved credential is used]
  4. ~/.notaion/config.json is set up
    4.1 both credHelpers and credsStore are configured. [expect: only credHeplers is honored]
    4.2 only credsStore is configured. [expect: credsStore is honored]
  5. ~/.docker/config.json is set up while ~/.notaion/config.json not
    5.1 both credHelpers and credsStore are configured. [expect: only credHeplers is honored]
    5.2 only credsStore is configured. [expect: credsStore is honored]
  • Will create another PR to complete the unit tests

Signed-off-by: Binbin Li libinbin@microsoft.com

@binbin-li binbin-li force-pushed the notation-login branch 6 times, most recently from d0f53d4 to 2f02aa0 Compare July 1, 2022 06:51
@binbin-li binbin-li changed the title [WIP] feat: support notation login feat: support notation login Jul 1, 2022
@binbin-li binbin-li force-pushed the notation-login branch 4 times, most recently from d5bc151 to ccdb1dd Compare July 4, 2022 09:14
cmd/notation/registry.go Outdated Show resolved Hide resolved
cmd/notation/registry.go Outdated Show resolved Hide resolved
internal/crypto/certificate.go Outdated Show resolved Hide resolved
internal/trace/transport.go Outdated Show resolved Hide resolved
pkg/dockerconfig/config.go Outdated Show resolved Hide resolved
pkg/auth/creds_config.go Outdated Show resolved Hide resolved
pkg/auth/creds_config.go Outdated Show resolved Hide resolved
pkg/auth/creds_config.go Outdated Show resolved Hide resolved
pkg/auth/native_passport.go Outdated Show resolved Hide resolved
pkg/auth/registry_remote.go Outdated Show resolved Hide resolved
@SteveLasker SteveLasker changed the title feat: support notation login [Feature]: support notation login Jul 5, 2022
@SteveLasker SteveLasker changed the title [Feature]: support notation login [Feature] support notation login Jul 5, 2022
@patrickzheng200
Copy link
Contributor

@shizhMSFT @binbin-li maybe we could split long PR like this one into multiple smaller PRs in the future to enhance the readability? (there are 20 files been added/updated in this PR) Please suggest if you think otherwise.

@binbin-li
Copy link
Contributor Author

@shizhMSFT @binbin-li maybe we could split long PR like this one into multiple smaller PRs in the future to enhance the readability? (there are 20 files been added/updated in this PR) Please suggest if you think otherwise.

You're right. I didn't expect this PR would be so large at the beginning. I would split long PRs next time.

cmd/notation/registry.go Outdated Show resolved Hide resolved
pkg/dockerconfig/config.go Outdated Show resolved Hide resolved
@@ -0,0 +1,115 @@
package dockerconfig
Copy link
Contributor

Choose a reason for hiding this comment

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

We can merge the dockerconfig package into a single file docker.go in the config package.

@binbin-li binbin-li force-pushed the notation-login branch 8 times, most recently from c97998f to 3caa631 Compare July 7, 2022 11:44
go.mod Outdated
github.com/notaryproject/notation-core-go v0.0.0-20220602183001-a7b72555a44b
github.com/notaryproject/notation-go v0.8.0-alpha.1.0.20220622031208-45f149e1b5ae
github.com/opencontainers/go-digest v1.0.0
github.com/urfave/cli/v2 v2.10.3
oras.land/oras-go/v2 v2.0.0-20220620164807-8b2a54608a94
oras.land/oras-go/v2 v2.0.0-alpha
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to upgrade oras-go to rc.1 in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll bump it up in a seperate PR

cmd/notation/registry.go Outdated Show resolved Hide resolved
cmd/notation/login.go Outdated Show resolved Hide resolved
pkg/auth/types.go Outdated Show resolved Hide resolved
pkg/config/docker_config.go Outdated Show resolved Hide resolved
pkg/config/docker_config.go Outdated Show resolved Hide resolved
pkg/config/docker_config.go Outdated Show resolved Hide resolved
pkg/auth/types.go Outdated Show resolved Hide resolved
pkg/auth/types.go Outdated Show resolved Hide resolved
pkg/auth/creds_config.go Outdated Show resolved Hide resolved
@binbin-li binbin-li force-pushed the notation-login branch 2 times, most recently from 6cc5439 to 5521311 Compare July 8, 2022 03:30
cmd/notation/registry.go Outdated Show resolved Hide resolved
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT added this to the RC-1 milestone Jul 8, 2022
@SteveLasker
Copy link
Contributor

I updated PR #119 to reflect the latest.
We should probably complete, then merge #119 before merging this one.

@binbin-li
Copy link
Contributor Author

binbin-li commented Jul 12, 2022

I updated PR #119 to reflect the latest. We should probably complete, then merge #119 before merging this one.

When referring to PR #119 , do you mean #223 ? @SteveLasker

@shizhMSFT
Copy link
Contributor

I updated PR #119 to reflect the latest. We should probably complete, then merge #119 before merging this one.

When referring to PR #119 , do you mean #223 ? @SteveLasker

#119 is an issue. It must be a typo and refers to #223.

@binbin-li Could you update this PR to reflect #223?

@binbin-li
Copy link
Contributor Author

I updated PR #119 to reflect the latest. We should probably complete, then merge #119 before merging this one.

When referring to PR #119 , do you mean #223 ? @SteveLasker

#119 is an issue. It must be a typo and refers to #223.

@binbin-li Could you update this PR to reflect #223?

Working on it.

@binbin-li
Copy link
Contributor Author

Updated as #223 defined.

  1. Moved --plain-http to the global options.
  2. Add --password-stdin option to login cmd.
  3. Add examples.

Copy link
Contributor

@SteveLasker SteveLasker left a comment

Choose a reason for hiding this comment

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

thanks @binbin-li
LGTM

@binbin-li binbin-li force-pushed the notation-login branch 2 times, most recently from 8af7cc5 to 41f9bca Compare July 18, 2022 06:58
Copy link
Contributor

@gokarnm gokarnm left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Binbin Li <libinbin@microsoft.com>
Signed-off-by: Binbin Li <libinbin@microsoft.com>
Signed-off-by: Binbin Li <libinbin@microsoft.com>
Signed-off-by: Binbin Li <libinbin@microsoft.com>
Signed-off-by: Binbin Li <libinbin@microsoft.com>
@gokarnm gokarnm merged commit bb5b497 into notaryproject:main Jul 20, 2022
@yizha1 yizha1 linked an issue Jul 25, 2022 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] notation login
5 participants