Skip to content

Commit ab21d48

Browse files
committed
update schema
1 parent 6225190 commit ab21d48

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,32 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [X.Y.Z] - 2022-MM-DD
8+
## [0.0.2] - 2024-12-19
9+
10+
### Added
11+
12+
- Cognito token authentication support with automatic refresh
13+
- Bearer token authentication for enhanced security
14+
- `TokenManager` class for token lifecycle management
15+
- `fetch_cognito_token()` function for Cognito integration
16+
- `get_auth_headers()` utility for authentication headers
17+
- Comprehensive test coverage for authentication features
18+
- Example scripts demonstrating token usage
19+
- Updated documentation for authentication configuration
20+
21+
### Changed
22+
23+
- Enhanced `SubmitDagByID` action to support multiple authentication methods
24+
- Added `httpx` dependency for modern HTTP client functionality
25+
- Maintained backward compatibility with existing basic auth
26+
27+
### Security
28+
29+
- Replaced basic authentication with more secure Bearer token authentication
30+
- Added automatic token refresh to prevent authentication failures
31+
- Implemented token caching to reduce API calls to Cognito
32+
33+
## [0.0.1] - 2022-MM-DD
934

1035
### Added
1136

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,63 @@ and a trigger event payload for a new file that was triggered:
160160

161161
In this case, the router sees that the action is `submit_dag_by_id` and thus makes a REST call to SPS to submit the URL payload, payload info, and `on_success` parameters as a DAG run. If the evaulator, running now as a DAG in SPS instead of an AWS Lambda function, successfully evaluates that everything is ready for this input file, it can proceed to submit a DAG run for the `submit_nisar_l0a_te_dag` DAG in the underlying SPS.
162162

163+
### Authentication for Airflow DAG Submissions
164+
165+
The `submit_dag_by_id` action supports multiple authentication methods for connecting to Airflow REST APIs. The authentication method is determined by the parameters provided in the router configuration:
166+
167+
#### 1. Bearer Token Authentication (Recommended)
168+
Use a direct bearer token for authentication. This is the most secure method:
169+
170+
```yaml
171+
actions:
172+
- name: submit_dag_by_id
173+
params:
174+
dag_id: example_dag
175+
airflow_base_api_endpoint: https://airflow.example.com/api/v1
176+
airflow_token: ${AIRFLOW_BEARER_TOKEN} # Bearer token
177+
```
178+
179+
#### 2. Cognito Token Authentication
180+
Use Unity Cognito credentials to automatically fetch and refresh tokens:
181+
182+
```yaml
183+
actions:
184+
- name: submit_dag_by_id
185+
params:
186+
dag_id: example_dag
187+
airflow_base_api_endpoint: https://airflow.example.com/api/v1
188+
unity_username: ${UNITY_USERNAME}
189+
unity_password: ${UNITY_PASSWORD}
190+
unity_client_id: ${UNITY_CLIENT_ID}
191+
unity_region: us-west-2 # Optional, defaults to us-west-2
192+
```
193+
194+
#### 3. Basic Authentication (Legacy)
195+
Use username/password for basic authentication (less secure):
196+
197+
```yaml
198+
actions:
199+
- name: submit_dag_by_id
200+
params:
201+
dag_id: example_dag
202+
airflow_base_api_endpoint: https://airflow.example.com/api/v1
203+
airflow_username: ${AIRFLOW_USERNAME}
204+
airflow_password: ${AIRFLOW_PASSWORD}
205+
```
206+
207+
#### Authentication Priority
208+
The system will use authentication in this order:
209+
1. **Bearer token** (if `airflow_token` is provided)
210+
2. **Cognito token** (if Unity credentials are provided)
211+
3. **Basic auth** (if username/password are provided)
212+
4. **No authentication** (if no credentials are provided)
213+
214+
#### Token Management
215+
When using Cognito authentication:
216+
- Tokens are automatically cached and refreshed 5 minutes before expiration
217+
- Failed token refresh attempts fall back to credential-based fetching
218+
- No manual token management required
219+
163220
<!-- ☝️ Replace with a more detailed description of your repository, including why it was made and whom its intended for. ☝️ -->
164221

165222
<!-- example links>

src/unity_initiator/resources/routers_schema.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ submit_dag_by_id_action:
4444
params:
4545
dag_id: str()
4646
airflow_base_api_endpoint: str(required=False)
47+
# Authentication parameters - supports multiple methods:
48+
# 1. Bearer token authentication (preferred)
49+
airflow_token: str(required=False)
50+
# 2. Cognito token authentication
51+
unity_username: str(required=False)
52+
unity_password: str(required=False)
53+
unity_client_id: str(required=False)
54+
unity_region: str(required=False)
55+
# 3. Basic authentication (fallback)
4756
airflow_username: str(required=False)
4857
airflow_password: str(required=False)
4958
on_success: include("on_success_actions", required=False)

0 commit comments

Comments
 (0)