Cognito support#8
Closed
pymonger wants to merge 8 commits into
Closed
Conversation
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.
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)TokenManagerclass: Handles Cognito token lifecycle with automatic refreshfetch_cognito_token(): High-level function for token retrievalget_auth_headers(): Generates appropriate authentication headersTokenInfodataclass: Structured token storage with expiration tracking�� Enhanced SubmitDagByID Action (
src/unity_initiator/actions/submit_dag_by_id.py)TokenManagerfor automatic token refresh📋 Router Schema Updates (
src/unity_initiator/resources/routers_schema.yaml)airflow_tokenfor Bearer token authenticationunity_username,unity_password,unity_client_id,unity_regionfor Cognito authenticationairflow_usernameandairflow_password📦 Dependencies
httpx: Modern HTTP client for token fetchingrequests: Maintained for compatibilitypyproject.tomlwith new dependencies�� Comprehensive Test Coverage
📚 Documentation and Examples
Authentication Flow
graph TD A[SubmitDagByID.execute] --> B{Token provided?} B -->|Yes| C[Use Bearer token] B -->|No| D{Cognito credentials?} D -->|Yes| E[Fetch Cognito token] D -->|No| F[Use Basic auth] E --> G[TokenManager.get_valid_token] G --> H{Cached token valid?} H -->|Yes| I[Use cached token] H -->|No| J[Fetch new token] J --> K[Cache and return token] I --> L[Make API request] K --> L C --> L F --> LConfiguration Examples
Bearer Token Authentication
Cognito Authentication
Basic Authentication (Fallback)
Benefits
Breaking Changes
Testing
Version Bump
src/unity_initiator/__about__.pyCHANGELOG.mdFiles 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.