This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and improve acorn login validation check (#922)
- Add --skip-checks as an escape hatch for trying to authenticate during `acorn login - Rename `acorn install --checks` to `acorn install --skip-checks` for symmetry - Fix the check itself so that authing against quay.io works (by removing the pull/push scopes from the authentication call) - Move the check server side Signed-off-by: Joshua Silverio <[email protected]> Signed-off-by: Craig Jellick <[email protected]> Co-authored-by: Craig Jellick <[email protected]>
- Loading branch information
1 parent
b316d34
commit ccc1be2
Showing
14 changed files
with
92 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package credentials | ||
|
||
import ( | ||
"context" | ||
"github.com/google/go-containerregistry/pkg/authn" | ||
"github.com/google/go-containerregistry/pkg/name" | ||
"github.com/google/go-containerregistry/pkg/v1/remote/transport" | ||
"net/http" | ||
) | ||
|
||
// credentialValidate takes a username, password and serverAddress string to validate | ||
// whether their combination is valid and will succeed login for pushes/pulls. | ||
func (s *Strategy) credentialValidate(ctx context.Context, username, password, serverAddress string) error { | ||
// Build a registry struct for the host | ||
reg, err := name.NewRegistry(serverAddress) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Build a new transport for the registry which validates authentication | ||
auth := &authn.Basic{Username: username, Password: password} | ||
_, err = transport.NewWithContext(ctx, reg, auth, http.DefaultTransport, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |