Skip to content

fix(login): support --password-stdin for piped input#944

Open
rambhardwajj wants to merge 1 commit into
goharbor:mainfrom
rambhardwajj:fix/password-stdin-login
Open

fix(login): support --password-stdin for piped input#944
rambhardwajj wants to merge 1 commit into
goharbor:mainfrom
rambhardwajj:fix/password-stdin-login

Conversation

@rambhardwajj
Copy link
Copy Markdown

Description

Fixes an issue with harbor login --password-stdin when password is provided via piped input
Previously, the login flow relied on term.ReadPassword(...), which expects an interactive terminal (TTY). This caused failures or incorrect behavior when stdin was non-interactive (e.g., piped input).

This change ensures correct handling of both interactive and piped stdin, and also fixes unintended password modification caused by trimming whitespace.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Use GetSecretStdin(...) to handle both interactive and piped stdin input
  • Detect non-TTY stdin and read password directly from input stream
  • Preserve leading/trailing whitespace in passwords (avoid TrimSpace)
  • Trim only newline characters (\r, \n)
  • Add unit tests for piped input and whitespace preservation

Signed-off-by: Ram Bhardwaj <rambhardwaj101000@gmail.com>
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.

[bug]: support --password-stdin for piped input and preserve whitespace

1 participant