httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.74k stars 3.68k forks source link

Accept configuration (or at least just authentication) on stdin #1476

Open ELLIOTTCABLE opened 1 year ago

ELLIOTTCABLE commented 1 year ago

Checklist


Enhancement request

Allow reading headers, instead of data, on standard input. (In particular, allowing the secure input of Authorization: Bearer ... etc, without interactive-mode input.)

Two possibilities to achieving this that I'm seeing off the top of my head,

  1. httpie --auth -, which only really helps with authentication,
  2. http pie.dev/headers X-Data:-, which is a little clumsier, but is more generalizable

Problem it solves

To avoid including sensitive authentication tokens on the command-line, you provide httpie --auth, which prompts for those values.

Unfortunately, that's not scriptable — so for automated tasks (e.g. when the secret is from an automated source, and not in your clipboard), you're stuck with the insecure-and-shown-in-ps positionals approach.


Additional information, screenshots, or code examples

It's worth noting that curl has this capability in the form of passing - to the -K flag, whence this Issue:

curl --request GET \
  --url "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/page_shield/connections" \
  -K- <<<'--header "Authorization: Bearer '"$(passage get api/cloudflare/read/token)"'"'