Skip to content

Refactor WebAuth session handling and improve error handling#5

Merged
fabieu merged 16 commits intomasterfrom
webauth-tests
Jan 1, 2026
Merged

Refactor WebAuth session handling and improve error handling#5
fabieu merged 16 commits intomasterfrom
webauth-tests

Conversation

@fabieu
Copy link
Owner

@fabieu fabieu commented Jan 1, 2026

This pull request introduces major improvements to the Steam web authentication code, focusing on refactoring for clarity, maintainability, and modern Python practices. The main changes include a significant rewrite of the steam/webauth.py authentication logic, enhancements to the HTTP session setup, and the addition of GitHub Actions workflows for automated testing and reporting.

Refactor and modernization of Steam web authentication:

  • Refactored steam/webauth.py to use more Pythonic naming conventions (PEP8), improved error handling, and clearer method separation. The authentication flow is now more robust, with methods like _start_login_session, _poll_login_status, and _finalize_login replacing older, less clear implementations. Headers and session handling are also improved for better emulation of a real browser. [1] [2] [3] [4] [5] [6] [7] [8]

  • Extracted and improved the HTTP session creation logic in steam/utils/web.py, allowing custom headers and simplifying session setup for all web requests. [1] [2]

Continuous integration improvements:

  • Added .github/workflows/test.yml to run tests across multiple OS and Python versions, and upload JUnit XML results as artifacts.
  • Added .github/workflows/test_report.yml to publish and display test reports from CI artifacts using the dorny/test-reporter action.

Developer experience enhancements:

  • Updated the Makefile to add a webauth_gen command for generating VCR cassettes for webauth tests, and improved the init target to install Poetry via pipx for consistent dependency management. [1] [2]This pull request refactors and modernizes the Steam web authentication logic, focusing on improving maintainability, API consistency, and code style. The changes introduce a more robust session creation mechanism, update authentication flows to use instance-level sessions with custom headers, and revise method and variable names to follow PEP8 conventions. Additionally, the test response scrubber is enhanced for better reliability and data anonymization.

Authentication and Session Handling Improvements

  • Updated the WebAuth class to use an instance-level requests.Session configured via the new make_requests_session utility, allowing for custom headers and better mimicking of browser behavior. [1] [2]
  • Refactored all authentication-related methods (send_api_request, _get_rsa_key, _start_session_with_credentials, _poll_login_status, _finalize_login, etc.) to consistently use the instance session and updated their signatures and logic for clarity and error handling. [1] [2] [3] [4] [5] [6] [7]

API Consistency and Code Style

  • Renamed methods and variables throughout steam/webauth.py to conform to PEP8 naming conventions, improving readability and maintainability. [1] [2]
  • Updated API endpoint formatting and removed unused global headers, ensuring all requests use the session's configured headers. [1] [2]

Testing and Data Scrubbing

  • Enhanced the response scrubber in tests/generete_webauth_vcr.py to defensively handle byte/string conversion and comprehensively anonymize sensitive fields in test recordings. Also, improved VCR configuration for better test hygiene.

Minor Cleanups

  • Removed unused imports (such as gzip) and streamlined code for clarity.

User Experience Improvements

  • Improved CLI login prompts and error messaging for better user feedback during authentication. [1] [2]

These changes collectively make the authentication flow more robust, maintainable, and user-friendly, while also improving the reliability of automated tests.

@fabieu fabieu self-assigned this Jan 1, 2026
@fabieu fabieu added the enhancement New feature or request label Jan 1, 2026
@fabieu fabieu merged commit 68071cc into master Jan 1, 2026
0 of 18 checks passed
@fabieu fabieu deleted the webauth-tests branch January 1, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant