airflow-file-auth-manager 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- airflow_file_auth_manager/endpoints.py +17 -15
- airflow_file_auth_manager/file_auth_manager.py +2 -2
- airflow_file_auth_manager/templates/login.html +1 -1
- {airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/METADATA +1 -1
- {airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/RECORD +8 -8
- {airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/WHEEL +0 -0
- {airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/entry_points.txt +0 -0
- {airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/licenses/LICENSE +0 -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
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
8
|
|
|
9
|
-
from fastapi import FastAPI,
|
|
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
|
|
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,13 +92,17 @@ 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:
|
|
97
102
|
logger.warning("AUDIT: Login attempt with missing credentials")
|
|
98
103
|
if is_form_submission:
|
|
99
104
|
return RedirectResponse(
|
|
100
|
-
url="/auth/
|
|
105
|
+
url="/auth/login?error=Username+and+password+required",
|
|
101
106
|
status_code=303,
|
|
102
107
|
)
|
|
103
108
|
return JSONResponse(
|
|
@@ -112,7 +117,7 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
|
|
|
112
117
|
username, request.client.host if request.client else "unknown")
|
|
113
118
|
if is_form_submission:
|
|
114
119
|
return RedirectResponse(
|
|
115
|
-
url="/auth/
|
|
120
|
+
url="/auth/login?error=Invalid+username+or+password",
|
|
116
121
|
status_code=303,
|
|
117
122
|
)
|
|
118
123
|
return JSONResponse(
|
|
@@ -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
|
-
|
|
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
|
|
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 = (
|
|
@@ -167,7 +169,7 @@ def create_auth_app(auth_manager: FileAuthManager) -> FastAPI:
|
|
|
167
169
|
logger.info("AUDIT: User logged out (IP: %s)",
|
|
168
170
|
request.client.host if request.client else "unknown")
|
|
169
171
|
|
|
170
|
-
redirect_response = RedirectResponse(url="/auth/
|
|
172
|
+
redirect_response = RedirectResponse(url="/auth/login", status_code=303)
|
|
171
173
|
redirect_response.delete_cookie(key="airflow_jwt")
|
|
172
174
|
return redirect_response
|
|
173
175
|
|
|
@@ -89,14 +89,14 @@ class FileAuthManager(BaseAuthManager[FileUser]):
|
|
|
89
89
|
|
|
90
90
|
def get_url_login(self, *, next_url: str | None = None) -> str:
|
|
91
91
|
"""Get the login page URL."""
|
|
92
|
-
url = "/auth/
|
|
92
|
+
url = "/auth/login"
|
|
93
93
|
if next_url:
|
|
94
94
|
url = f"{url}?{urlencode({'next': next_url})}"
|
|
95
95
|
return url
|
|
96
96
|
|
|
97
97
|
def get_url_logout(self) -> str:
|
|
98
98
|
"""Get the logout URL."""
|
|
99
|
-
return "/auth/
|
|
99
|
+
return "/auth/logout"
|
|
100
100
|
|
|
101
101
|
# =========================================================================
|
|
102
102
|
# Serialization Methods (for JWT)
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
|
|
196
196
|
<p class="description">Enter your username and password below:</p>
|
|
197
197
|
|
|
198
|
-
<form action="/auth/
|
|
198
|
+
<form action="/auth/token" method="POST">
|
|
199
199
|
<input type="hidden" name="next" value="{{ next_url }}">
|
|
200
200
|
|
|
201
201
|
<div class="form-group">
|
{airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: airflow-file-auth-manager
|
|
3
|
-
Version: 0.1.
|
|
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
|
{airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/RECORD
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
airflow_file_auth_manager/__init__.py,sha256=M1nQascdVasmnx9yih96Htl-Z626KIVAtALBJ9KyCd0,993
|
|
2
2
|
airflow_file_auth_manager/cli.py,sha256=seJ5Vu1R763DFVfd3tsBIk6RaGIXlarB1gSu3WVv03c,8935
|
|
3
|
-
airflow_file_auth_manager/endpoints.py,sha256=
|
|
4
|
-
airflow_file_auth_manager/file_auth_manager.py,sha256=
|
|
3
|
+
airflow_file_auth_manager/endpoints.py,sha256=bX-9kHjyZu3H11QhYVwb-dQhuZTTFuL1kChm6vnFTx8,6300
|
|
4
|
+
airflow_file_auth_manager/file_auth_manager.py,sha256=hRTudfXHL6c0OMptArFmSP1vWbNsBpfHRbTtsLfO1e4,13081
|
|
5
5
|
airflow_file_auth_manager/password.py,sha256=C-a6vjOxnht9X4OE_xrlvWH1DaEMJwK9OV20fE0OQJ8,2689
|
|
6
6
|
airflow_file_auth_manager/policy.py,sha256=luj1EhVAKLZxubr7h4Au171-R1Q_HmGb78QEWqWQync,5159
|
|
7
7
|
airflow_file_auth_manager/user.py,sha256=lxskYF8rQGEzgxKu6NzDtXLPtNRY2AspBKu89RiIEZg,2278
|
|
8
8
|
airflow_file_auth_manager/user_store.py,sha256=VV1D0vWlm5Z_l-bcXLEQpueY5Gfx7xUdUqBpFDLlLIA,11717
|
|
9
9
|
airflow_file_auth_manager/static/styles.css,sha256=-gxvqlQCHpZtif-93OpqgcyYTe__9Sr92Np-9N97S04,1675
|
|
10
|
-
airflow_file_auth_manager/templates/login.html,sha256=
|
|
11
|
-
airflow_file_auth_manager-0.1.
|
|
12
|
-
airflow_file_auth_manager-0.1.
|
|
13
|
-
airflow_file_auth_manager-0.1.
|
|
14
|
-
airflow_file_auth_manager-0.1.
|
|
15
|
-
airflow_file_auth_manager-0.1.
|
|
10
|
+
airflow_file_auth_manager/templates/login.html,sha256=OMHv2c6OsnMsKKXYFaQwnHzVtAjUQe9HSZgoaI2DGY8,8387
|
|
11
|
+
airflow_file_auth_manager-0.1.4.dist-info/METADATA,sha256=wXnEUxAXQZHqFDlRBcTyDEB-LGBuEeI0m1qQLeLn0oQ,11041
|
|
12
|
+
airflow_file_auth_manager-0.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
13
|
+
airflow_file_auth_manager-0.1.4.dist-info/entry_points.txt,sha256=bQgxFNgbmAewrv9RAZ_tYUNZy5IxS_Zhlj6vgG9lbqY,168
|
|
14
|
+
airflow_file_auth_manager-0.1.4.dist-info/licenses/LICENSE,sha256=fw8CKBXZ_-V6K5pxfUmJP3e_7QUvFq8XncuZ27tvarg,10177
|
|
15
|
+
airflow_file_auth_manager-0.1.4.dist-info/RECORD,,
|
{airflow_file_auth_manager-0.1.2.dist-info → airflow_file_auth_manager-0.1.4.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|