Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions airflow-core/docs/core-concepts/auth-manager/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ If you want to check which auth manager is currently set, you can use the
$ airflow config get-value core auth_manager
airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager

.. toctree::
:hidden:

simple/index

Available auth managers to use
------------------------------

Here is the list of auth managers available today that you can use in your Airflow environment.

Provided by Airflow:

.. toctree::
:maxdepth: 1

simple
* :doc:`simple/index`

Provided by providers:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Simple auth manager
The simple auth manager is the auth manager that comes by default in Airflow 3. As its name suggests,
the logic and implementation of the simple auth manager is **simple**.

.. toctree::
:maxdepth: 1

token
sam-token-api-ref


Manage users
------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

Simple auth manager token API
=============================

It's a stub file. It will be converted automatically during the build process
to the valid documentation by the Sphinx plugin. See: /docs/conf.py
49 changes: 49 additions & 0 deletions airflow-core/docs/core-concepts/auth-manager/simple/token.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

Generate JWT token with simple auth manager
===========================================

.. note::
This guide only applies if your environment is configured with simple auth manager.

In order to use the :doc:`Airflow public API </stable-rest-api-ref>`, you need a JWT token for authentication.
You can then include this token in your Airflow public API requests.
To generate a JWT token, use the ``Create Token`` API in :doc:`sam-token-api-ref`.

Example
'''''''

.. code-block:: bash

ENDPOINT_URL="http://localhost:8080/"
curl -X 'POST' \
"${ENDPOINT_URL}/auth/token" \
-H 'Content-Type: application/json' \
-d '{
"username": "<username>",
"password": "<password>"
}'

This process will return a token that you can use in the Airflow public API requests.

If ``[core] simple_auth_manager_all_admins`` is set to True, you can also generate a token with no credentials.

.. code-block:: bash

ENDPOINT_URL="http://localhost:8080/"
curl -X 'GET' "${ENDPOINT_URL}/auth/token"
41 changes: 24 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,38 +903,45 @@ def filter_ignore(record: logging.LogRecord) -> bool:
redoc_script_url = "https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.48/bundles/redoc.standalone.js"

if PACKAGE_NAME == "apache-airflow":
OPENAPI_FILE = (
Path(__file__).parents[1]
/ "airflow-core"
/ "src"
/ "airflow"
/ "api_fastapi"
/ "core_api"
/ "openapi"
/ "v1-generated.yaml"
)
from airflow.api_fastapi.auth.managers.simple.openapi import __file__ as sam_openapi_file
from airflow.api_fastapi.core_api.openapi import __file__ as main_openapi_file

main_openapi_path = Path(main_openapi_file).parent.joinpath("v1-generated.yaml")
sam_openapi_path = Path(sam_openapi_file).parent.joinpath("v1-generated.yaml")
redoc = [
{
"name": "Airflow REST API",
"page": "stable-rest-api-ref",
"spec": OPENAPI_FILE.as_posix(),
"spec": main_openapi_path.as_posix(),
"opts": {
"hide-hostname": True,
"no-auto-auth": True,
},
},
{
"name": "Simple auth manager token API",
"page": "core-concepts/auth-manager/simple/sam-token-api-ref",
"spec": sam_openapi_path.as_posix(),
"opts": {
"hide-hostname": True,
},
},
]
elif PACKAGE_NAME == "apache-airflow-providers-fab":
from airflow.providers.fab.auth_manager import __file__ as auth_manager_path
from airflow.providers.fab.auth_manager.api_fastapi.openapi import (
__file__ as fab_auth_manager_fastapi_api_file,
)
from airflow.providers.fab.auth_manager.openapi import __file__ as fab_auth_manager_flask_api_file

fab_flask_openapi_file = Path(auth_manager_path).parent.joinpath("openapi", "v1.yaml")
fab_fastapi_openapi_file = Path(auth_manager_path).parent.joinpath(
"api_fastapi", "openapi", "v1-generated.yaml"
fab_auth_manager_flask_api_path = Path(fab_auth_manager_flask_api_file).parent.joinpath("v1.yaml")
fab_auth_manager_fastapi_api_path = Path(fab_auth_manager_fastapi_api_file).parent.joinpath(
"v1-generated.yaml"
)
redoc = [
{
"name": "Fab auth manager API",
"page": "api-ref/fab-public-api-ref",
"spec": fab_flask_openapi_file.as_posix(),
"spec": fab_auth_manager_flask_api_path.as_posix(),
"opts": {
"hide-hostname": True,
"no-auto-auth": True,
Expand All @@ -943,7 +950,7 @@ def filter_ignore(record: logging.LogRecord) -> bool:
{
"name": "Fab auth manager token API",
"page": "api-ref/fab-token-api-ref",
"spec": fab_fastapi_openapi_file.as_posix(),
"spec": fab_auth_manager_fastapi_api_path.as_posix(),
"opts": {
"hide-hostname": True,
"no-auto-auth": True,
Expand Down
10 changes: 5 additions & 5 deletions providers/fab/docs/auth-manager/token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
specific language governing permissions and limitations
under the License.

Generate JWT token for Airflow public API
=========================================
Generate JWT token with FAB auth manager
========================================

.. note::
This guide only applies if your environment is configured with FAB auth manager.

In order to use the :doc:`Airflow public API <apache-airflow:stable-rest-api-ref>`, you need a JWT token to authenticate yourself.
Then you can use this token in the Airflow public API request to access it.
To generate a JWT token, you need to use the API ``Create Token`` in :doc:`/api-ref/fab-token-api-ref`.
In order to use the :doc:`Airflow public API <apache-airflow:stable-rest-api-ref>`, you need a JWT token for authentication.
You can then include this token in your Airflow public API requests.
To generate a JWT token, use the ``Create Token`` API in :doc:`/api-ref/fab-token-api-ref`.

Example
'''''''
Expand Down