airflow-file-auth-manager 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/PKG-INFO +1 -1
  2. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/pyproject.toml +1 -1
  3. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/endpoints.py +14 -12
  4. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/.gitignore +0 -0
  5. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/LICENSE +0 -0
  6. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/README.md +0 -0
  7. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/examples/users.yaml +0 -0
  8. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/__init__.py +0 -0
  9. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/cli.py +0 -0
  10. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/file_auth_manager.py +0 -0
  11. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/password.py +0 -0
  12. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/policy.py +0 -0
  13. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/static/styles.css +0 -0
  14. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/templates/login.html +0 -0
  15. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/user.py +0 -0
  16. {airflow_file_auth_manager-0.1.3 → airflow_file_auth_manager-0.1.4}/src/airflow_file_auth_manager/user_store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airflow-file-auth-manager
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: YAML file-based lightweight Auth Manager for Apache Airflow 3.x
5
5
  Project-URL: Homepage, https://github.com/choo121600/airflow-file-auth-manager
6
6
  Project-URL: Repository, https://github.com/choo121600/airflow-file-auth-manager
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "airflow-file-auth-manager"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "YAML file-based lightweight Auth Manager for Apache Airflow 3.x"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -4,9 +4,9 @@ from __future__ import annotations
4
4
 
5
5
  import logging
6
6
  from pathlib import Path
7
- from typing import TYPE_CHECKING, Annotated
7
+ from typing import TYPE_CHECKING
8
8
 
9
- from fastapi import FastAPI, Form, Request, Response
9
+ from fastapi import FastAPI, Request, Response
10
10
  from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
11
11
  from fastapi.staticfiles import StaticFiles
12
12
  from jinja2 import Environment, FileSystemLoader
@@ -66,8 +66,6 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
66
66
  async def create_token(
67
67
  request: Request,
68
68
  response: Response,
69
- username: Annotated[str | None, Form()] = None,
70
- password: Annotated[str | None, Form()] = None,
71
69
  ) -> Response:
72
70
  """Authenticate user and create JWT token.
73
71
 
@@ -77,9 +75,12 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
77
75
  - Browser sessions: HttpOnly cookies (protected from XSS)
78
76
  - API clients: Bearer tokens in response body (use Authorization header)
79
77
  """
80
- # Handle JSON request
78
+ # Handle request based on content type
81
79
  content_type = request.headers.get("content-type", "")
82
80
  is_form_submission = "application/x-www-form-urlencoded" in content_type
81
+ username: str | None = None
82
+ password: str | None = None
83
+ form_data = None
83
84
 
84
85
  if "application/json" in content_type:
85
86
  try:
@@ -91,6 +92,10 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
91
92
  status_code=400,
92
93
  content={"error": "Invalid JSON body"},
93
94
  )
95
+ elif is_form_submission:
96
+ form_data = await request.form()
97
+ username = form_data.get("username")
98
+ password = form_data.get("password")
94
99
 
95
100
  # Validate input
96
101
  if not username or not password:
@@ -120,19 +125,16 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
120
125
  content={"error": "Invalid username or password"},
121
126
  )
122
127
 
123
- # Create JWT token
124
- from airflow.api_fastapi.auth.tokens import create_jwt_token
125
-
126
- token_payload = auth_manager.serialize_user(user)
127
- token = create_jwt_token(token_payload, expiration_seconds=jwt_expiration)
128
+ # Create JWT token using auth manager's method
129
+ token = auth_manager.generate_jwt(user, expiration_time_in_seconds=jwt_expiration)
128
130
 
129
131
  logger.info("AUDIT: User logged in: %s (IP: %s)",
130
132
  username, request.client.host if request.client else "unknown")
131
133
 
132
134
  # Form submission - set HttpOnly cookie and redirect
133
135
  if is_form_submission:
134
- form_data = await request.form()
135
- next_url = form_data.get("next", "/")
136
+ # form_data was already read above
137
+ next_url = form_data.get("next", "/") if form_data else "/"
136
138
 
137
139
  # Detect if using HTTPS
138
140
  is_secure = (