Skip to content

Commit 415166f

Browse files
authored
Synchronize FAB provider with 1.5.4 version (#61601)
This change synchronizes the code of upcoming provider 1.5.4 to the v2-11-test branch. Unlike the usual release where providers are released from main - for 2.11.1 we will have to release both 2.11.1 and Fab provider 1.5.4 at the same time, becuase there are very tight dependency changes between them. In order to make testing easier, we copied the latest 1.5.3 changes to v11-tests and applied all modifications in dependencies to make FAB provider 1.5.4 works together with Airflow 2.11.1. There will be a very tight coupling there when we release - at least at the moment of release of the provider - i.e. airflow 2.11.1 will work only with FAB provider >=1.5.4 because of those dependency changes. However, we should be able to release 1.5.5 and further from the samve v2-11-test branch from now on, and test them together with upcoming 2.11.2+ airlow releases (if there will be some) so it makes sense to couple them together in v2-11-test branch.
1 parent 90f7c39 commit 415166f

File tree

69 files changed

+4640
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4640
-239
lines changed

airflow/providers/fab/CHANGELOG.rst

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,151 @@
2020
Changelog
2121
---------
2222

23+
1.5.4
24+
.....
25+
26+
* ``[providers-fab/v1-5] Update dependencies for FAB provider to not be conflicting with 2.11.1 (#53029)``
27+
28+
.. Below changes are excluded from the changelog. Move them to
29+
appropriate section above if needed. Do not delete the lines(!):
30+
31+
32+
1.5.3
33+
.....
34+
35+
Bug Fixes
36+
~~~~~~~~~
37+
38+
* ``[providers-fab/v1-5] Use different default algorithms for different werkzeug versions (#46384) (#46392)``
39+
40+
Misc
41+
~~~~
42+
43+
* ``[providers-fab/v1-5] Upgrade to FAB 4.5.3 (#45874) (#45918)``
44+
45+
.. Below changes are excluded from the changelog. Move them to
46+
appropriate section above if needed. Do not delete the lines(!):
47+
48+
1.5.2
49+
.....
50+
51+
Misc
52+
~~~~
53+
54+
* ``Correctly import isabs from os.path (#45178)``
55+
* ``[providers-fab/v1-5] Invalidate user session on password reset (#45139)``
56+
57+
58+
.. Below changes are excluded from the changelog. Move them to
59+
appropriate section above if needed. Do not delete the lines(!):
60+
61+
1.5.1
62+
.....
63+
64+
Bug Fixes
65+
~~~~~~~~~
66+
67+
* ``fab_auth_manager: allow get_user method to return the user authenticated via Kerberos (#43662)``
68+
69+
70+
.. Below changes are excluded from the changelog. Move them to
71+
appropriate section above if needed. Do not delete the lines(!):
72+
* ``Expand and improve the kerberos api authentication documentation (#43682)``
73+
74+
1.5.0
75+
.....
76+
77+
Features
78+
~~~~~~~~
79+
80+
* ``feat(providers/fab): Use asset in common provider (#43112)``
81+
82+
Bug Fixes
83+
~~~~~~~~~
84+
85+
* ``fix revoke Dag stale permission on airflow < 2.10 (#42844)``
86+
* ``fix(providers/fab): alias is_authorized_dataset to is_authorized_asset (#43469)``
87+
* ``fix: Change CustomSecurityManager method name (#43034)``
88+
89+
Misc
90+
~~~~
91+
92+
* ``Upgrade Flask-AppBuilder to 4.5.2 (#43309)``
93+
* ``Upgrade Flask-AppBuilder to 4.5.1 (#43251)``
94+
* ``Move user and roles schemas to fab provider (#42869)``
95+
* ``Move the session auth backend to FAB auth manager (#42878)``
96+
* ``Add logging to the migration commands (#43516)``
97+
* ``DOC fix documentation error in 'apache-airflow-providers-fab/access-control.rst' (#43495)``
98+
* ``Rename dataset as asset in UI (#43073)``
99+
100+
.. Below changes are excluded from the changelog. Move them to
101+
appropriate section above if needed. Do not delete the lines(!):
102+
* ``Split providers out of the main "airflow/" tree into a UV workspace project (#42505)``
103+
* ``Start porting DAG definition code to the Task SDK (#43076)``
104+
* ``Prepare docs for Oct 2nd wave of providers (#43409)``
105+
* ``Prepare docs for Oct 2nd wave of providers RC2 (#43540)``
106+
107+
1.4.1
108+
.....
109+
110+
Misc
111+
~~~~
112+
113+
* ``Update Rest API tests to no longer rely on FAB auth manager. Move tests specific to FAB permissions to FAB provider (#42523)``
114+
* ``Rename dataset related python variable names to asset (#41348)``
115+
* ``Simplify expression for get_permitted_dag_ids query (#42484)``
116+
117+
118+
.. Below changes are excluded from the changelog. Move them to
119+
appropriate section above if needed. Do not delete the lines(!):
120+
121+
1.4.0
122+
.....
123+
124+
Features
125+
~~~~~~~~
126+
127+
* ``Add FAB migration commands (#41804)``
128+
* ``Separate FAB migration from Core Airflow migration (#41437)``
129+
130+
Misc
131+
~~~~
132+
133+
* ``Deprecated kerberos auth removed (#41693)``
134+
* ``Deprecated configuration removed (#42129)``
135+
* ``Move 'is_active' user property to FAB auth manager (#42042)``
136+
* ``Move 'register_views' to auth manager interface (#41777)``
137+
* ``Revert "Provider fab auth manager deprecated methods removed (#41720)" (#41960)``
138+
* ``Provider fab auth manager deprecated methods removed (#41720)``
139+
* ``Make kerberos an optional and devel dependency for impala and fab (#41616)``
140+
141+
142+
.. Below changes are excluded from the changelog. Move them to
143+
appropriate section above if needed. Do not delete the lines(!):
144+
* ``Add TODOs in providers code for Subdag code removal (#41963)``
145+
* ``Add fixes by breeze/precommit-lint static checks (#41604) (#41618)``
146+
147+
.. Review and move the new changes to one of the sections above:
148+
* ``Fix pre-commit for auto update of fab migration versions (#42382)``
149+
* ``Handle 'AUTH_ROLE_PUBLIC' in FAB auth manager (#42280)``
150+
151+
1.3.0
152+
.....
153+
154+
Features
155+
~~~~~~~~
156+
157+
* ``Feature: Allow set Dag Run resource into Dag Level permission (#40703)``
158+
159+
Misc
160+
~~~~
161+
162+
* ``Remove deprecated SubDags (#41390)``
163+
164+
165+
.. Below changes are excluded from the changelog. Move them to
166+
appropriate section above if needed. Do not delete the lines(!):
167+
23168
1.2.2
24169
.....
25170

airflow/providers/fab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
__all__ = ["__version__"]
3131

32-
__version__ = "1.2.2"
32+
__version__ = "1.5.4"
3333

3434
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
3535
"2.9.0"

airflow/providers/fab/alembic.ini

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# A generic, single database configuration.
19+
20+
[alembic]
21+
# path to migration scripts
22+
# Use forward slashes (/) also on windows to provide an os agnostic path
23+
script_location = %(here)s/migrations
24+
25+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
26+
# Uncomment the line below if you want the files to be prepended with date and time
27+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
28+
# for all available tokens
29+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
30+
31+
# sys.path path, will be prepended to sys.path if present.
32+
# defaults to the current working directory.
33+
prepend_sys_path = .
34+
35+
# timezone to use when rendering the date within the migration file
36+
# as well as the filename.
37+
# If specified, requires the python>=3.9 or backports.zoneinfo library.
38+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
39+
# string value is passed to ZoneInfo()
40+
# leave blank for localtime
41+
# timezone =
42+
43+
# max length of characters to apply to the "slug" field
44+
# truncate_slug_length = 40
45+
46+
# set to 'true' to run the environment during
47+
# the 'revision' command, regardless of autogenerate
48+
# revision_environment = false
49+
50+
# set to 'true' to allow .pyc and .pyo files without
51+
# a source .py file to be detected as revisions in the
52+
# versions/ directory
53+
# sourceless = false
54+
55+
# version location specification; This defaults
56+
# to alembic/versions. When using multiple version
57+
# directories, initial revisions must be specified with --version-path.
58+
# The path separator used here should be the separator specified by "version_path_separator" below.
59+
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
60+
61+
# version path separator; As mentioned above, this is the character used to split
62+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
63+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
64+
# Valid values for version_path_separator are:
65+
#
66+
# version_path_separator = :
67+
# version_path_separator = ;
68+
# version_path_separator = space
69+
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
70+
71+
# set to 'true' to search source files recursively
72+
# in each "version_locations" directory
73+
# new in Alembic version 1.10
74+
# recursive_version_locations = false
75+
76+
# the output encoding used when revision files
77+
# are written from script.py.mako
78+
# output_encoding = utf-8
79+
80+
sqlalchemy.url = scheme://localhost/airflow
81+
82+
83+
[post_write_hooks]
84+
# post_write_hooks defines scripts or Python functions that are run
85+
# on newly generated revision scripts. See the documentation for further
86+
# detail and examples
87+
88+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
89+
# hooks = black
90+
# black.type = console_scripts
91+
# black.entrypoint = black
92+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
93+
94+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
95+
# hooks = ruff
96+
# ruff.type = exec
97+
# ruff.executable = %(here)s/.venv/bin/ruff
98+
# ruff.options = --fix REVISION_SCRIPT_FILENAME
99+
100+
# Logging configuration
101+
[loggers]
102+
keys = root,sqlalchemy,alembic
103+
104+
[handlers]
105+
keys = console
106+
107+
[formatters]
108+
keys = generic
109+
110+
[logger_root]
111+
level = WARN
112+
handlers = console
113+
qualname =
114+
115+
[logger_sqlalchemy]
116+
level = WARN
117+
handlers =
118+
qualname = sqlalchemy.engine
119+
120+
[logger_alembic]
121+
level = INFO
122+
handlers =
123+
qualname = alembic
124+
125+
[handler_console]
126+
class = StreamHandler
127+
args = (sys.stderr,)
128+
level = NOTSET
129+
formatter = generic
130+
131+
[formatter_generic]
132+
format = %(levelname)-5.5s [%(name)s] %(message)s
133+
datefmt = %H:%M:%S

airflow/providers/fab/auth_manager/api/auth/backend/basic_auth.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from functools import wraps
2222
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
2323

24-
from flask import Response, request
24+
from flask import Response, current_app, request
2525
from flask_appbuilder.const import AUTH_LDAP
2626
from flask_login import login_user
2727

@@ -62,9 +62,23 @@ def requires_authentication(function: T):
6262

6363
@wraps(function)
6464
def decorated(*args, **kwargs):
65-
if auth_current_user() is not None:
65+
# Try to authenticate the user
66+
user = auth_current_user()
67+
if user is not None:
6668
return function(*args, **kwargs)
67-
else:
69+
70+
# Authentication failed - check if Authorization header was provided
71+
auth_header = request.headers.get("Authorization")
72+
if auth_header:
73+
# Authorization header was present but authentication failed
74+
# This includes malformed headers that Flask couldn't parse
6875
return Response("Unauthorized", 401, {"WWW-Authenticate": "Basic"})
6976

77+
# No Authorization header - check if public access is allowed
78+
if current_app.config.get("AUTH_ROLE_PUBLIC", None):
79+
return function(*args, **kwargs)
80+
81+
# No auth header and no public access
82+
return Response("Unauthorized", 401, {"WWW-Authenticate": "Basic"})
83+
7084
return cast(T, decorated)

0 commit comments

Comments
 (0)