Skip to content

Commit

Permalink
pkg/auth: add NoWriteBack option
Browse files Browse the repository at this point in the history
Add an option to not write back the credentials to the authfile or any
credential helper.  The `/auth` compat endpoint of Podman is currently
not using this code here which ultimately led to normalization errors
surfacing in containers/podman/issues/17571.

The new option allows the endpoint to use this function without writing
back the credentials.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
  • Loading branch information
vrothberg committed Mar 21, 2023
1 parent e40de25 commit d56f647
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/auth/auth.go
Expand Up @@ -160,16 +160,16 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO
}

if err = docker.CheckAuth(ctx, systemContext, username, password, registry); err == nil {
// Write the new credentials to the authfile
desc, err := config.SetCredentials(systemContext, key, username, password)
if err != nil {
return err
}
if opts.Verbose {
fmt.Fprintln(opts.Stdout, "Used: ", desc)
if !opts.NoWriteBack {
// Write the new credentials to the authfile
desc, err := config.SetCredentials(systemContext, key, username, password)
if err != nil {
return err
}
if opts.Verbose {
fmt.Fprintln(opts.Stdout, "Used: ", desc)
}
}
}
if err == nil {
fmt.Fprintln(opts.Stdout, "Login Succeeded!")
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/auth/cli.go
Expand Up @@ -26,6 +26,7 @@ type LoginOptions struct {
Stdin io.Reader // set to os.Stdin
Stdout io.Writer // set to os.Stdout
AcceptUnspecifiedRegistry bool // set to true if allows login with unspecified registry
NoWriteBack bool // set to true to not write the credentials to the authfile/cred helpers
}

// LogoutOptions represents the results for flags in logout
Expand Down

0 comments on commit d56f647

Please sign in to comment.