Skip to content

Commit c8648f0

Browse files
committed
pass password via stdin
1 parent 986eee8 commit c8648f0

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

aws_login_headless/aws_login_headless.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,15 @@ run_playwright_automation() {
257257
echo "Launching headless browser automation..."
258258

259259
# Build uvx command with inline script dependencies
260+
# Password is passed via stdin for security (not visible in process list)
260261
local uvx_cmd=(
261262
"uvx"
262263
"--from" "playwright"
263264
"--with" "playwright"
264265
"python"
265266
"$PLAYWRIGHT_SCRIPT"
266267
"$verification_url"
267-
"$password"
268+
"--password-stdin"
268269
)
269270

270271
if [[ -n "$username" ]]; then
@@ -282,7 +283,8 @@ run_playwright_automation() {
282283
fi
283284
fi
284285

285-
if "${uvx_cmd[@]}"; then
286+
# Pass password via stdin to prevent exposure in process list
287+
if echo "$password" | "${uvx_cmd[@]}"; then
286288
echo ""
287289
echo "✓ Successfully authenticated to AWS SSO"
288290
echo ""

aws_login_headless/aws_login_headless_playwright.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ def parse_args():
2828
help="AWS SSO verification URL from 'aws sso login --no-browser'"
2929
)
3030
parser.add_argument(
31-
"sso_password",
32-
help="AWS SSO password (retrieve from 1Password or provide directly)"
31+
"--password-stdin",
32+
action="store_true",
33+
help="Read password from stdin instead of command line"
3334
)
3435
parser.add_argument(
3536
"--username",
@@ -307,9 +308,19 @@ def main():
307308
"""Main entry point."""
308309
args = parse_args()
309310

311+
# Read password from stdin if flag is set
312+
if args.password_stdin:
313+
sso_password = sys.stdin.read().strip()
314+
if not sso_password:
315+
print("Error: No password provided via stdin", file=sys.stderr)
316+
sys.exit(1)
317+
else:
318+
print("Error: Password must be provided via --password-stdin", file=sys.stderr)
319+
sys.exit(1)
320+
310321
success = aws_sso_login(
311322
verification_url=args.verification_url,
312-
sso_password=args.sso_password,
323+
sso_password=sso_password,
313324
username=args.username,
314325
headless=args.headless,
315326
timeout=args.timeout

0 commit comments

Comments
 (0)