Skip to content

Commit c18dfa9

Browse files
authored
Update FAB provider documentation (apache#48247)
1 parent 80840cb commit c18dfa9

File tree

11 files changed

+151
-98
lines changed

11 files changed

+151
-98
lines changed

airflow-core/docs/redirects.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ administration-and-deployment/security/access-control/index.rst ../apache-airflo
3131
administration-and-deployment/security/api.rst security/api.rst
3232
administration-and-deployment/security/audit_logs.rst security/audit_logs.rst
3333
administration-and-deployment/security/flower.rst security/flower.rst
34-
administration-and-deployment/security/webserver.rst security/webserver.rst
34+
administration-and-deployment/security/webserver.rst ../apache-airflow-providers-fab/stable/auth-manager/security.rst
3535
administration-and-deployment/security/workload.rst security/workload.rst
3636
administration-and-deployment/security/secrets/secrets-backends/index.rst security/secrets/secrets-backends/index.rst
3737
administration-and-deployment/security/secrets/secrets-backends/local-filesystem-secrets-backend.rst security/secrets/secrets-backends/local-filesystem-secrets-backend.rst

docs/conf.py

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
if PACKAGE_NAME != "apache-airflow":
130130
global_substitutions["experimental"] = "This is an :external:ref:`experimental feature <experimental>`."
131131

132-
133132
# == Sphinx configuration ======================================================
134133

135134
# -- Project information -------------------------------------------------------
@@ -168,6 +167,21 @@
168167
"substitution_extensions",
169168
"sphinx_design",
170169
]
170+
171+
172+
packages_with_redoc = ["apache-airflow", "apache-airflow-providers-fab"]
173+
if PACKAGE_NAME in packages_with_redoc:
174+
extensions.extend(
175+
[
176+
"autoapi.extension",
177+
# First, generate redoc
178+
"sphinxcontrib.redoc",
179+
# Second, update redoc script
180+
"sphinx_script_update",
181+
]
182+
)
183+
184+
171185
if PACKAGE_NAME == "apache-airflow":
172186
extensions.extend(
173187
[
@@ -176,14 +190,9 @@
176190
"sphinxcontrib.httpdomain",
177191
"sphinxcontrib.httpdomain",
178192
"extra_files_with_substitutions",
179-
# First, generate redoc
180-
"sphinxcontrib.redoc",
181-
# Second, update redoc script
182-
"sphinx_script_update",
183193
]
184194
)
185-
186-
if PACKAGE_NAME == "apache-airflow-providers":
195+
elif PACKAGE_NAME == "apache-airflow-providers":
187196
extensions.extend(
188197
[
189198
"sphinx_jinja",
@@ -203,8 +212,9 @@
203212
"providers_extensions",
204213
]
205214
)
206-
else:
215+
elif PACKAGE_NAME not in packages_with_redoc:
207216
extensions.append("autoapi.extension")
217+
208218
# List of patterns, relative to source directory, that match files and
209219
# directories to ignore when looking for source files.
210220
exclude_patterns: list[str]
@@ -888,6 +898,10 @@ def filter_ignore(record: logging.LogRecord) -> bool:
888898

889899
# -- Options for sphinxcontrib.redoc -------------------------------------------
890900
# See: https://sphinxcontrib-redoc.readthedocs.io/en/stable/
901+
if PACKAGE_NAME in packages_with_redoc:
902+
# Options for script updater
903+
redoc_script_url = "https://cdn.jsdelivr.net/npm/[email protected]/bundles/redoc.standalone.js"
904+
891905
if PACKAGE_NAME == "apache-airflow":
892906
OPENAPI_FILE = (
893907
Path(__file__).parents[1]
@@ -910,27 +924,34 @@ def filter_ignore(record: logging.LogRecord) -> bool:
910924
},
911925
},
912926
]
913-
914-
# Options for script updater
915-
redoc_script_url = "https://cdn.jsdelivr.net/npm/[email protected]/bundles/redoc.standalone.js"
916-
917927
elif PACKAGE_NAME == "apache-airflow-providers-fab":
918-
OPENAPI_FILE = Path(__file__).parents[1] / "providers" / "fab" / "auth_manager" / "openapi" / "v1.yaml"
928+
from airflow.providers.fab.auth_manager import __file__ as auth_manager_path
929+
930+
fab_flask_openapi_file = Path(auth_manager_path).parent.joinpath("openapi", "v1.yaml")
931+
fab_fastapi_openapi_file = Path(auth_manager_path).parent.joinpath(
932+
"api_fastapi", "openapi", "v1-generated.yaml"
933+
)
919934
redoc = [
920935
{
921-
"name": "Fab provider REST API",
922-
"page": "stable-rest-api-ref",
923-
"spec": OPENAPI_FILE.as_posix(),
936+
"name": "Fab auth manager API",
937+
"page": "api-ref/fab-public-api-ref",
938+
"spec": fab_flask_openapi_file.as_posix(),
939+
"opts": {
940+
"hide-hostname": True,
941+
"no-auto-auth": True,
942+
},
943+
},
944+
{
945+
"name": "Fab auth manager token API",
946+
"page": "api-ref/fab-token-api-ref",
947+
"spec": fab_fastapi_openapi_file.as_posix(),
924948
"opts": {
925949
"hide-hostname": True,
926950
"no-auto-auth": True,
927951
},
928952
},
929953
]
930954

931-
# Options for script updater
932-
redoc_script_url = "https://cdn.jsdelivr.net/npm/[email protected]/bundles/redoc.standalone.js"
933-
934955

935956
def skip_util_classes(app, what, name, obj, skip, options):
936957
if what == "data" and "STATICA_HACK" in name:

providers/fab/docs/stable-rest-api-ref.rst renamed to providers/fab/docs/api-ref/fab-public-api-ref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
specific language governing permissions and limitations
1717
under the License.
1818
19-
REST API Reference
20-
==================
19+
FAB auth manager API
20+
====================
2121

2222
It's a stub file. It will be converted automatically during the build process
2323
to the valid documentation by the Sphinx plugin. See: /docs/conf.py
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
.. Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
.. http://www.apache.org/licenses/LICENSE-2.0
11+
12+
.. Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
19+
FAB auth manager token API
20+
==========================
21+
22+
It's a stub file. It will be automatically converted during the build process into valid documentation by the Sphinx plugin. See: /docs/conf.py

providers/fab/docs/auth-manager/access-control.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
specific language governing permissions and limitations
1616
under the License.
1717
18-
Access Control
19-
==============
18+
Access Control with FAB auth manager
19+
====================================
2020

21-
Access Control of Airflow Webserver UI is handled by Flask AppBuilder (FAB).
21+
FAB auth manager access control is handled by Flask AppBuilder (FAB).
2222
Please read its related `security document <http://flask-appbuilder.readthedocs.io/en/latest/security.html>`_
2323
regarding its security model.
2424

@@ -33,7 +33,7 @@ regarding its security model.
3333

3434
Default Roles
3535
'''''''''''''
36-
Airflow ships with a set of roles by default: Admin, User, Op, Viewer, and Public.
36+
FAB auth manager ships with a set of roles by default: Admin, User, Op, Viewer, and Public.
3737
By default, only ``Admin`` users can configure/alter permissions for roles. However,
3838
it is recommended that these default roles remain unaltered, and instead ``Admin`` users
3939
create new roles with the desired permissions if changes are necessary.
@@ -110,7 +110,7 @@ Permissions
110110

111111
.. warning::
112112

113-
Airflow allows you to define custom Roles with fine-grained RBAC permissions for users. However, not all
113+
FAB auth manager allows you to define custom Roles with fine-grained RBAC permissions for users. However, not all
114114
combinations of permissions are fully consistent, and there is no mechanism to make sure that the set of
115115
permissions assigned is fully consistent. There are a number of cases where permissions for
116116
particular resources are overlapping. A good example is menu access permissions - a lack of menu access
@@ -125,7 +125,7 @@ Permissions
125125
Resource-Based permissions
126126
^^^^^^^^^^^^^^^^^^^^^^^^^^
127127

128-
Starting with version 2.0, permissions are based on individual resources and a small subset of actions on those
128+
Permissions are based on individual resources and a small subset of actions on those
129129
resources. Resources match standard Airflow concepts, such as ``Dag``, ``DagRun``, ``Task``, and
130130
``Connection``. Actions include ``can_create``, ``can_read``, ``can_edit``, and ``can_delete``.
131131

@@ -138,7 +138,10 @@ There are five default roles: Public, Viewer, User, Op, and Admin. Each one has
138138
DAG-level permissions
139139
^^^^^^^^^^^^^^^^^^^^^
140140

141-
For DAG-level permissions exclusively, access can be controlled at the level of all DAGs or individual DAG objects. This includes ``DAGs.can_read``, ``DAGs.can_edit``, ``DAGs.can_delete``, ``DAG Runs.can_read``, ``DAG Runs.can_create``, ``DAG Runs.can_delete``, and ``DAG Runs.menu_access``. When these permissions are listed, access is granted to users who either have the listed permission or the same permission for the specific DAG being acted upon. For individual DAGs, the resource name is ``DAG:`` + the DAG ID, or for the DAG Runs resource the resource name is ``DAG Run:``.
141+
For DAG-level permissions exclusively, access can be controlled at the level of all DAGs or individual DAG objects.
142+
This includes ``DAGs.can_read``, ``DAGs.can_edit``, ``DAGs.can_delete``, ``DAG Runs.can_read``, ``DAG Runs.can_create``, ``DAG Runs.can_delete``, and ``DAG Runs.menu_access``.
143+
When these permissions are listed, access is granted to users who either have the listed permission or the same permission for the specific DAG being acted upon.
144+
For individual DAGs, the resource name is ``DAG:`` + the DAG ID, or for the DAG Runs resource the resource name is ``DAG Run:``.
142145

143146
For example, if a user is trying to view DAG information for the ``example_dag_id``, and the endpoint requires ``DAGs.can_read`` access, access will be granted if the user has either ``DAGs.can_read`` or ``DAG:example_dag_id.can_read`` access.
144147

providers/fab/docs/auth-manager/api-authentication.rst

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,25 @@
1515
specific language governing permissions and limitations
1616
under the License.
1717
18-
API Authentication
19-
==================
18+
FAB auth manager API authentication
19+
===================================
2020

21-
Authentication for the API is handled separately to the Web Authentication. The default is to
22-
check the user session:
21+
.. note::
22+
This guide only applies to :doc:`FAB auth manager API </api-ref/fab-public-api-ref>`.
23+
24+
Authentication for the APIs is handled by what is called an authentication backend. The default is to check the user session:
2325

2426
.. code-block:: ini
2527
26-
[api]
28+
[fab]
2729
auth_backends = airflow.providers.fab.auth_manager.api.auth.backend.session
2830
29-
.. versionchanged:: 1.10.11
30-
31-
In Airflow <1.10.11, the default setting was to allow all API requests without authentication, but this
32-
posed security risks for if the Webserver is publicly accessible.
33-
34-
.. versionchanged:: 2.3.0
35-
36-
In Airflow <2.3.0 this setting was ``auth_backend`` and allowed only one
37-
value. In 2.3.0 it was changed to support multiple backends that are tried
38-
in turn.
39-
40-
If you want to check which authentication backends are currently set, you can use ``airflow config get-value api auth_backends``
31+
If you want to check which authentication backends are currently set, you can use ``airflow config get-value fab auth_backends``
4132
command as in the example below.
4233

4334
.. code-block:: console
4435
45-
$ airflow config get-value api auth_backends
36+
$ airflow config get-value fab auth_backends
4637
airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
4738
4839
.. versionchanged:: 3.0.0
@@ -51,30 +42,6 @@ command as in the example below.
5142
This approach is independent from which ``auth_backend`` is used.
5243
The default setting is using Airflow public API to create a token (JWT) first and use this token in the requests to access the API.
5344

54-
55-
JWT Token based authentication
56-
''''''''''''''''''''''''''''''
57-
The JWT token based authentication is the default setting for the API.
58-
To be able to use the Airflow Public API, you need to create a token first and use this token in the requests to access the API.
59-
60-
Endpoints are populated under ``/auth`` path. These endpoints are mounted to the Airflow API.
61-
You should use your username and password, as seen in the example below.
62-
The token is valid for seconds defined in ``auth_jwt_expiration_time`` which can be set from ``airflow.cfg``.
63-
64-
Example of creating a token:
65-
.. code-block:: bash
66-
67-
curl -X 'POST' \
68-
'http://localhost:32784/auth/token' \
69-
-H 'accept: application/json' \
70-
-H 'Content-Type: application/json' \
71-
-d '{
72-
"username": "username",
73-
"password": "password"
74-
}'
75-
76-
This process will return a token that you can use in the requests to access the API.
77-
7845
Kerberos authentication
7946
'''''''''''''''''''''''
8047

@@ -84,7 +51,7 @@ To enable Kerberos authentication, set the following in the configuration:
8451

8552
.. code-block:: ini
8653
87-
[api]
54+
[fab]
8855
auth_backends = airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth
8956
9057
[kerberos]
@@ -109,7 +76,7 @@ work. This means that your user name should be ``user_name@REALM``.
10976
11077
.. note::
11178

112-
Remember that the stable API is secured by both authentication and `access control <./access-control.html>`_.
79+
Remember that the APIs are secured by both authentication and `access control <./access-control.html>`_.
11380
This means that your user needs to have a Role with necessary associated permissions, otherwise you'll receive
11481
a 403 response.
11582

@@ -125,7 +92,7 @@ To enable basic authentication, set the following in the configuration:
12592

12693
.. code-block:: ini
12794
128-
[api]
95+
[fab]
12996
auth_backends = airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
13097
13198
Username and password needs to be base64 encoded and send through the
@@ -162,7 +129,7 @@ and may have one of the following to support API client authorizations used by :
162129
* function ``create_client_session() -> requests.Session``
163130
* attribute ``CLIENT_AUTH: tuple[str, str] | requests.auth.AuthBase | None``
164131

165-
After writing your backend module, provide the fully qualified module name in the ``auth_backends`` key in the ``[api]``
132+
After writing your backend module, provide the fully qualified module name in the ``auth_backends`` key in the ``[fab]``
166133
section of ``airflow.cfg``.
167134

168135
Additional options to your auth backend can be configured in ``airflow.cfg``, as a new option.

providers/fab/docs/auth-manager/index.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@
1818
Flask AppBuilder (FAB) auth manager
1919
===================================
2020

21-
FAB auth (for authentication/authorization) manager is the auth manager that comes by default with Airflow. This auth manager defines the user authentication and user authorization by default in Airflow.
21+
FAB auth (for authentication/authorization) manager defines the user authentication and user authorization in Airflow.
2222
The backend used to store all entities used by the FAB auth manager is the Airflow database: :doc:`apache-airflow:database-erd-ref`.
2323

2424
.. image:: ../img/diagram_fab_auth_manager_airflow_architecture.png
2525

2626
Follow the below topics as well to understand other aspects of FAB auth manager:
2727

28+
* :doc:`token`. Use FAB auth manager to generate a JWT token in order to call Airflow public API
29+
* :doc:`api-authentication`. How to authenticate the API provided by FAB auth manager
30+
* :doc:`access-control`. How FAB auth manager manage users and permissions
31+
* :doc:`webserver-authentication`. To learn the different options available in FAB auth manager to authenticate users
32+
* :doc:`security`. To learn the different options available in FAB auth manager to secure the UI provided by FAB auth manager
33+
2834
.. toctree::
35+
:hidden:
2936
:maxdepth: 1
3037
:glob:
3138

airflow-core/docs/security/webserver.rst renamed to providers/fab/docs/auth-manager/security.rst

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
specific language governing permissions and limitations
1616
under the License.
1717
18-
Webserver
19-
=========
18+
FAB auth manager UI security options
19+
====================================
2020

21-
This topic describes how to configure Airflow to secure your webserver.
21+
.. note::
22+
This guide only applies to FAB auth manager UI pages. These pages are accessible under category "Security" in the
23+
menu.
2224

2325
Rendering Airflow UI in a Web Frame from another site
2426
------------------------------------------------------
@@ -48,14 +50,6 @@ Sensitive Variable fields
4850
Variable values that are deemed "sensitive" based on the variable name will be masked in the UI automatically.
4951
See :ref:`security:mask-sensitive-values` for more details.
5052

51-
.. _web-authentication:
52-
53-
Web Authentication
54-
------------------
55-
56-
The webserver authentication is handled by the auth manager. For more information about webserver authentication, please refer to the auth manager documentation used by your environment.
57-
By default Airflow uses the FAB auth manager, if you did not specify any other auth manager, please look at :doc:`apache-airflow-providers-fab:auth-manager/webserver-authentication`.
58-
5953
SSL
6054
---
6155

0 commit comments

Comments
 (0)