Cognito support #8
Closed
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.
PR Summary: Add Cognito Token Support and Bearer Authentication to Unity Initiator
Overview
This PR adds comprehensive token-based authentication support to the Unity Initiator project, replacing basic authentication with modern Bearer token authentication and Cognito integration.
Key Changes
�� New Authentication Utilities (
src/unity_initiator/utils/auth_utils.py
)TokenManager
class: Handles Cognito token lifecycle with automatic refreshfetch_cognito_token()
: High-level function for token retrievalget_auth_headers()
: Generates appropriate authentication headersTokenInfo
dataclass: Structured token storage with expiration tracking�� Enhanced SubmitDagByID Action (
src/unity_initiator/actions/submit_dag_by_id.py
)TokenManager
for automatic token refresh📋 Router Schema Updates (
src/unity_initiator/resources/routers_schema.yaml
)airflow_token
for Bearer token authenticationunity_username
,unity_password
,unity_client_id
,unity_region
for Cognito authenticationairflow_username
andairflow_password
📦 Dependencies
httpx
: Modern HTTP client for token fetchingrequests
: Maintained for compatibilitypyproject.toml
with new dependencies�� Comprehensive Test Coverage
📚 Documentation and Examples
Authentication Flow
Configuration Examples
Bearer Token Authentication
Cognito Authentication
Basic Authentication (Fallback)
Benefits
Breaking Changes
Testing
Version Bump
src/unity_initiator/__about__.py
CHANGELOG.md
Files Changed
src/unity_initiator/utils/auth_utils.py
(new)src/unity_initiator/actions/submit_dag_by_id.py
(modified)src/unity_initiator/resources/routers_schema.yaml
(updated)pyproject.toml
(dependencies added)tests/test_auth_utils.py
(new)tests/test_submit_dag_by_id.py
(new)tests/resources/test_router_with_auth.yaml
(new)examples/router_with_cognito_auth.yaml
(new)README.md
(updated with authentication documentation)src/unity_initiator/__about__.py
(version bump)CHANGELOG.md
(updated)This PR provides a robust, production-ready authentication system that enhances security while maintaining full backward compatibility and proper schema validation.