← Back to issue list

fix(auth): reject malformed credential storage hostnames

View original Github issue

Metadata

Project
craft-store
Number
#459
Type
pull request
State
open
Author
barkya28
Labels
—
Created
Updated
Closed
—

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

Summary Fixes #260. This PR improves hostname validation in craft_store.auth.Auth to prevent invalid host values from being used when storing or retrieving credentials from the system keyring. Previously, passing a full URL instead of a hostname could result in credential lookup failures because the keyring used a different service identifier. Changes Made * Added hostname validation during Auth initialization. * Rejects invalid host values containing URL schemes, ports, paths, or malformed hostname labels. * Raises a clear ValueError when an invalid hostname is provided. * Updated the integration-test fixture to extract the hostname from the Charmhub base URL. * Added parametrized unit tests covering valid and invalid hostname inputs. Testing * Added unit tests for valid hostname formats. * Added tests for malformed hostnames, URLs, and ports. * The full repository test suite has not yet been run. Expected Behaviour Valid hostnames such as api.charmhub.io are accepted. Invalid inputs such as https://api.charmhub.io and api.charmhub.io:443 are rejected with a descriptive error. This helps prevent credential storage mismatches and makes authentication configuration errors easier to diagnose. Closes #260.

Evaluation history

No evaluation history available.

Update history

Date Change
created

Related issues

No embedding available for this issue yet. Run scripts/run_llm.py evaluate to enable similarity search.