fix(login): prevent env var auth leak in guest sessions#267
Open
fix(login): prevent env var auth leak in guest sessions#267
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flash loginhangs at "Waiting for authorization..." whenRUNPOD_API_KEYis set (env var or credentials file from a previous login)api_key_override or get_api_key()in all three HTTP session factories conflated "no override provided" with "explicitly no auth" — theorfallback picked up existing credentials and sent a Bearer token, so the server never saw a guest caller_UNSETsentinel default soapi_key_override=None(login flow) means "send no auth" while omitting the parameter preserves existing credential resolutionTest plan
api_key_override=NonewithRUNPOD_API_KEYset — all 3 session factories omit Authorization headerrequire_api_key=Falsewith env var set — GraphQL client session has no auth (exact bug scenario)make quality-checkpasses (85% coverage)RUNPOD_API_KEY, runflash login --force, verify it completesflash login, verify create request succeeds