Skip to content

feat(alias): prompt for missing credentials on a terminal - #415

Open
42m4n wants to merge 1 commit into
rustfs:mainfrom
42m4n:feat/alias-prompt-credentials
Open

42m4n wants to merge 1 commit into
rustfs:mainfrom
42m4n:feat/alias-prompt-credentials

Conversation

@42m4n

@42m4n 42m4n commented Nov 9, 2026 •

Copy link
Copy Markdown

Summary

  • rc alias set required the access key and the secret key on the command line.
  • A command such as rc alias set local http://localhost:9000 MYKEY MYSECRET is saved in bash history as plain text.
  • Anyone who reads ~/.bash_history, or the terminal scrollback, can see the credentials.
  • Keys on the command line also appear in ps output while the command runs.
  • Prompt for the missing keys when stdin is a terminal and output is not JSON. Prompted input is not saved in shell history.

Changes

  • Prompt with Enter Access Key: and read the value with echo on.
  • Prompt with Enter Secret Key: and read the value with echo off.
  • No prompt when --json is set or stdin is not a terminal. Non-interactive runs keep the current error:
    Access key and secret key are required unless --anonymous is set, exit code 2.
  • Prompt failures report the existing error mapping. An interrupt exits with 130.
  • Document the new behavior in docs/reference/rc/alias.md.

Behavior notes

  • This matches mc alias set from MinIO.
  • No breaking change. Existing invocations with both keys still work with the same output and exit codes.
  • Scripts that run with an attached tty and no keys now wait for input instead of failing fast.
    This is the same trade-off as mc.

Testing

  • cargo fmt --all --check — pass
  • cargo clippy --workspace -- -D warnings — pass
  • cargo test --workspace — pass
  • Verified in a pty: the access key is echoed, the secret key is not echoed, and an interrupt exits with 130.

Running 'rc alias set' without keys wrote the credentials into shell history when they were passed on the command line. Prompt instead when stdin is a terminal and output is not JSON.

The access key is echoed and the secret key is hidden, matching 'mc alias set'. Non-interactive runs keep the existing usage error so scripts and CI do not hang. Interactive prompts use the existing SecretSource and read_code_interactive helpers.
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.

1 participant