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

refactor: use oras-credentials-go for credential management #654

Merged
merged 2 commits into from May 23, 2023

Conversation

Wwwsylvia
Copy link
Contributor

Resolves: #600
Resolves: #637

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2023

Codecov Report

Merging #654 (16be413) into main (5fdefed) will decrease coverage by 2.23%.
The diff coverage is 20.61%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
- Coverage   61.35%   59.13%   -2.23%     
==========================================
  Files          42       40       -2     
  Lines        2280     2183      -97     
==========================================
- Hits         1399     1291     -108     
- Misses        782      795      +13     
+ Partials       99       97       -2     
Impacted Files Coverage Δ
cmd/notation/login.go 26.08% <0.00%> (-3.19%) ⬇️
cmd/notation/logout.go 50.00% <0.00%> (+5.88%) ⬆️
internal/auth/credentials.go 0.00% <0.00%> (ø)
cmd/notation/registry.go 61.95% <55.55%> (-5.97%) ⬇️
cmd/notation/common.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Wwwsylvia Wwwsylvia changed the title refactor: use oras-credentials-go refactor: use oras-credentials-go for credential management Apr 27, 2023
@Wwwsylvia Wwwsylvia changed the title refactor: use oras-credentials-go for credential management refactor: use oras-credentials-go for credential management Apr 27, 2023
@Wwwsylvia
Copy link
Contributor Author

Wwwsylvia commented Apr 27, 2023

Behaviors of this PR

notation login

  • If the provided credential is invalid or the connection to registry fails, throw an error
    Screenshot 2023-05-11 113659

  • If there is a credentials store configured in the notation config file

    • Save the credential into the configured credentials store
  • If no credentials store is configured, or the notation config file does not exist

    • Use the platform-default credentials store, and set it back to the notation config file
    • If the platform-default credentials store is not installed
      • If the provided credential is identical with the existing credential, print:
        image
      • If the provided credential is different with the saved one, throw an error
        image

notation logout

  • If there is a credentials store configured in the notation config file
    • Remove the credential of the registry
  • If no credentials store is configured, or the notation config file does not exist
    • No operation

Other notation operations that require authentication

Look for the credentials in following order:

  1. notation config file
  • Configured credential helpers
  • Configured credentials store
  • Platform-default credentials store
  • Plaintext credentials
  1. Docker config file
  • Configured credential helpers
  • Configured credentials store
  • Platform-default credentials store
  • Plaintext credentials

Related links

@Wwwsylvia

This comment was marked as duplicate.

@Wwwsylvia Wwwsylvia marked this pull request as ready for review April 28, 2023 02:26
@Wwwsylvia Wwwsylvia marked this pull request as draft April 28, 2023 03:20
@Wwwsylvia Wwwsylvia force-pushed the use_orascreds branch 4 times, most recently from a3b8249 to 9059f99 Compare April 28, 2023 03:50
@Wwwsylvia Wwwsylvia marked this pull request as ready for review April 28, 2023 04:19
cmd/notation/registry.go Outdated Show resolved Hide resolved
@Wwwsylvia Wwwsylvia marked this pull request as draft May 8, 2023 12:05
@Wwwsylvia Wwwsylvia marked this pull request as ready for review May 9, 2023 03:01
@Wwwsylvia Wwwsylvia force-pushed the use_orascreds branch 3 times, most recently from a2adf1a to 2850ed0 Compare May 10, 2023 11:46
@Wwwsylvia
Copy link
Contributor Author

I'm still trying to understand this process. So, under what circumstances does Notation login/logout perform write operations (if any) on the Docker config file?

notation will never write to the Docker config file.
If no credentials store is configured, or the notation config file does not exist, notation will use the platform-default credentials store, and set the "credsStore" field back to the notation config file.

Two-Hearts
Two-Hearts previously approved these changes May 18, 2023
Copy link
Contributor

@Two-Hearts Two-Hearts left a comment

Choose a reason for hiding this comment

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

LGTM

JeyJeyGao
JeyJeyGao previously approved these changes May 19, 2023
Copy link
Contributor

@JeyJeyGao JeyJeyGao 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 previously approved these changes May 19, 2023
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 with nit.

cmd/notation/login.go Outdated Show resolved Hide resolved
@Wwwsylvia Wwwsylvia dismissed stale reviews from shizhMSFT, JeyJeyGao, and Two-Hearts via dac7cd4 May 19, 2023 06:37
JeyJeyGao
JeyJeyGao previously approved these changes May 19, 2023
Copy link
Contributor

@JeyJeyGao JeyJeyGao left a comment

Choose a reason for hiding this comment

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

LGTM

Two-Hearts
Two-Hearts previously approved these changes May 19, 2023
Copy link
Contributor

@Two-Hearts Two-Hearts 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 previously approved these changes May 19, 2023
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

@Wwwsylvia Wwwsylvia requested a review from ningziwen May 19, 2023 10:08
Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
cmd/notation/login.go Show resolved Hide resolved
cmd/notation/login.go Show resolved Hide resolved
Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@JeyJeyGao JeyJeyGao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Two-Hearts Two-Hearts left a comment

Choose a reason for hiding this comment

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

LGTM

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 merged commit a695b60 into notaryproject:main May 23, 2023
4 checks passed
@Wwwsylvia Wwwsylvia deleted the use_orascreds branch May 23, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants