Skip to content

feat: implement authentication module with Basic and Bearer policies#15

Merged
musale merged 4 commits into
mainfrom
feat/pluggable-auth
Aug 21, 2025
Merged

feat: implement authentication module with Basic and Bearer policies#15
musale merged 4 commits into
mainfrom
feat/pluggable-auth

Conversation

@musale

@musale musale commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces a new, extensible authentication system for the gavaconnect Python SDK, supporting both Basic and Bearer (OAuth2) authentication schemes. It adds dedicated modules for authentication logic, provides concurrency-safe token management, and includes comprehensive tests and documentation. The changes also update development dependencies and testing configuration to support asynchronous code.

Authentication System Implementation:

  • Added gavaconnect/auth/basic.py implementing BasicAuthPolicy and immutable BasicCredentials for HTTP Basic authentication.
  • Added gavaconnect/auth/bearer.py defining a pluggable AuthPolicy protocol, BearerAuthPolicy for bearer tokens, and a TokenProvider protocol for token management.
  • Added gavaconnect/auth/providers.py with ClientCredentialsProvider for OAuth2 client credentials flow, supporting concurrency-safe caching and early refresh.
  • Created gavaconnect/auth/__init__.py to expose authentication classes and protocols as the public API.

Documentation:

  • Added gavaconnect/auth/README.md detailing the authentication architecture, design goals, and rationale for per-resource authentication.

Testing and Coverage:

  • Added tests/test_auth_basic.py with thorough unit tests for BasicCredentials and BasicAuthPolicy, including immutability, header formation, and async methods.
  • Updated coverage.xml to reflect new modules and increased test coverage across authentication code. [1] [2]

Development and Testing Configuration:

  • Updated pyproject.toml to add pytest-asyncio and respx for async and HTTP mocking support, and configured pytest for asyncio mode and markers. [1] [2] [3]

@musale musale requested a review from Copilot August 21, 2025 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a comprehensive authentication system for the gavaconnect Python SDK, introducing support for both Basic and Bearer (OAuth2) authentication schemes. The implementation focuses on per-resource authentication policies, thread-safe token management, and extensible design patterns.

  • Implements pluggable authentication policies for Basic and Bearer token authentication
  • Adds OAuth2 client credentials provider with concurrency-safe token caching and early refresh
  • Provides comprehensive test coverage for all authentication components with async testing support

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gavaconnect/auth/init.py Exposes authentication classes and protocols as public API
gavaconnect/auth/basic.py Implements BasicAuthPolicy and immutable BasicCredentials for HTTP Basic authentication
gavaconnect/auth/bearer.py Defines AuthPolicy protocol and BearerAuthPolicy for bearer token authentication
gavaconnect/auth/providers.py Implements ClientCredentialsProvider for OAuth2 client credentials flow with caching
gavaconnect/auth/README.md Documents authentication architecture and design rationale
tests/test_auth_basic.py Unit tests for basic authentication implementation
tests/test_auth_bearer.py Unit tests for bearer authentication with mock and integration scenarios
tests/test_auth_providers.py Comprehensive tests for token provider implementations
tests/test_auth_module.py Tests for module imports and exports
pyproject.toml Adds async testing dependencies and configuration
coverage.xml Updated coverage report reflecting new authentication modules

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov

codecov Bot commented Aug 21, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@musale musale merged commit 4354ba1 into main Aug 21, 2025
4 checks passed
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.

2 participants