Skip to content

fix(login): prevent env var auth leak in guest sessions#267

Open
deanq wants to merge 8 commits intomainfrom
deanq/ae-2442-fix-flash-login
Open

fix(login): prevent env var auth leak in guest sessions#267
deanq wants to merge 8 commits intomainfrom
deanq/ae-2442-fix-flash-login

Conversation

@deanq
Copy link
Member

@deanq deanq commented Mar 12, 2026

Summary

  • flash login hangs at "Waiting for authorization..." when RUNPOD_API_KEY is set (env var or credentials file from a previous login)
  • Root cause: api_key_override or get_api_key() in all three HTTP session factories conflated "no override provided" with "explicitly no auth" — the or fallback picked up existing credentials and sent a Bearer token, so the server never saw a guest caller
  • Introduces _UNSET sentinel default so api_key_override=None (login flow) means "send no auth" while omitting the parameter preserves existing credential resolution

Test plan

  • New test: api_key_override=None with RUNPOD_API_KEY set — all 3 session factories omit Authorization header
  • New test: require_api_key=False with env var set — GraphQL client session has no auth (exact bug scenario)
  • Existing tests continue to pass (default credential resolution unchanged)
  • make quality-check passes (85% coverage)
  • Manual: set RUNPOD_API_KEY, run flash login --force, verify it completes
  • Manual: unset all keys, run flash login, verify create request succeeds

deanq added 8 commits March 11, 2026 17:08
…t sessions

Session factories conflated "no override provided" with "explicitly no auth"
via `api_key_override or get_api_key()`. When RunpodGraphQLClient set
api_key_override=None for require_api_key=False, the `or` fallback picked up
RUNPOD_API_KEY from the environment, causing flash login to send a Bearer token
instead of acting as a guest. The server then never returned an apiKey.

Introduces _UNSET sentinel so api_key_override=None means "send no auth" while
omitting the parameter preserves existing credential resolution.
…uth scenarios

- Replace mocked get_api_key test with real credential resolution (fresh user)
- Add test: credentials file has key + require_api_key=False → no auth header
- Add test: both env var and credentials file + require_api_key=False → no auth header
Remove _read_credentials references (no longer exists), RUNPOD_CREDENTIALS_FILE
env var usage, and clear=True from patch.dict calls. All tests now use the
autouse isolate_credentials_file fixture and write runpod-python profile format
([default] section). Also fix credentials.py to read CREDENTIAL_FILE dynamically
via module reference (enables monkeypatch) and catch TOMLDecodeError from
get_credentials() for corrupt file handling.
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