-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create auth manager documentation #36211
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fcd3d4b
Create auth manager documentation
vincbeck 856e7b0
Update docs/apache-airflow/security/api.rst
vincbeck 22abba1
Update docs/apache-airflow/security/webserver.rst
vincbeck c7a8b6d
Update docs/apache-airflow/core-concepts/auth-manager.rst
vincbeck 11ebe54
Update docs/apache-airflow/core-concepts/auth-manager.rst
vincbeck 0eb086d
Address feedbacks
vincbeck 6178f16
Fix docs
vincbeck f5c36ce
Fix docs
vincbeck b04810c
Move pictures
vincbeck c4017ed
Fix docs
vincbeck 6afddcd
Merge branch 'main' into vincbeck/auth_manager_doc
vincbeck 99adb0a
Test
vincbeck e86674d
Revert "Test"
vincbeck e94df3a
Add diagram to explain concept of auth manager
vincbeck 1cf65c9
Update diagrams
vincbeck 688755a
Add diagram for FAB auth manager
vincbeck f8a57e9
Merge branch 'main' into vincbeck/auth_manager_doc
vincbeck 8eff81f
Save FAB diagram in FAB provider
vincbeck eb79315
Merge branch 'main' into vincbeck/auth_manager_doc
vincbeck 2679abb
Remove references to FAB provider
vincbeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
137 changes: 137 additions & 0 deletions
137
docs/apache-airflow-providers-fab/auth-manager/api-authentication.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
.. 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. | ||
|
||
API Authentication | ||
================== | ||
|
||
Authentication for the API is handled separately to the Web Authentication. The default is to | ||
check the user session: | ||
|
||
.. code-block:: ini | ||
|
||
[api] | ||
auth_backends = airflow.api.auth.backend.session | ||
|
||
.. versionchanged:: 1.10.11 | ||
|
||
In Airflow <1.10.11, the default setting was to allow all API requests without authentication, but this | ||
posed security risks for if the Webserver is publicly accessible. | ||
|
||
.. versionchanged:: 2.3.0 | ||
|
||
In Airflow <2.3.0 this setting was ``auth_backend`` and allowed only one | ||
value. In 2.3.0 it was changed to support multiple backends that are tried | ||
in turn. | ||
|
||
If you want to check which authentication backends are currently set, you can use ``airflow config get-value api auth_backends`` | ||
command as in the example below. | ||
|
||
.. code-block:: console | ||
|
||
$ airflow config get-value api auth_backends | ||
airflow.api.auth.backend.basic_auth | ||
|
||
Disable authentication | ||
'''''''''''''''''''''' | ||
|
||
If you wish to have the experimental API work, and aware of the risks of enabling this without authentication | ||
(or if you have your own authentication layer in front of Airflow) you can set the following in ``airflow.cfg``: | ||
|
||
.. code-block:: ini | ||
|
||
[api] | ||
auth_backends = airflow.api.auth.backend.default | ||
|
||
.. note:: | ||
|
||
You can only disable authentication for experimental API, not the stable REST API. | ||
|
||
See :doc:`apache-airflow:administration-and-deployment/modules_management` for details on how Python and Airflow manage modules. | ||
|
||
Kerberos authentication | ||
''''''''''''''''''''''' | ||
|
||
Kerberos authentication is currently supported for the API. | ||
|
||
To enable Kerberos authentication, set the following in the configuration: | ||
|
||
.. code-block:: ini | ||
|
||
[api] | ||
auth_backends = airflow.api.auth.backend.kerberos_auth | ||
|
||
[kerberos] | ||
keytab = <KEYTAB> | ||
|
||
The Kerberos service is configured as ``airflow/fully.qualified.domainname@REALM``. Make sure this | ||
principal exists in the keytab file. | ||
|
||
You have to make sure to name your users with the kerberos full username/realm in order to make it | ||
works. This means that your user name should be ``user_name@KERBEROS-REALM``. | ||
|
||
Basic authentication | ||
'''''''''''''''''''' | ||
|
||
`Basic username password authentication <https://en.wikipedia.org/wiki/Basic_access_authentication>`_ is currently | ||
supported for the API. This works for users created through LDAP login or | ||
within Airflow Metadata DB using password. | ||
|
||
To enable basic authentication, set the following in the configuration: | ||
|
||
.. code-block:: ini | ||
|
||
[api] | ||
auth_backends = airflow.api.auth.backend.basic_auth | ||
|
||
Username and password needs to be base64 encoded and send through the | ||
``Authorization`` HTTP header in the following format: | ||
|
||
.. code-block:: text | ||
|
||
Authorization: Basic Base64(username:password) | ||
|
||
Here is a sample curl command you can use to validate the setup: | ||
|
||
.. code-block:: bash | ||
|
||
ENDPOINT_URL="http://localhost:8080/" | ||
curl -X GET \ | ||
--user "username:password" \ | ||
"${ENDPOINT_URL}/api/v1/pools" | ||
|
||
Note, you can still enable this setting to allow API access through username | ||
password credential even though Airflow webserver might be using another | ||
authentication method. Under this setup, only users created through LDAP or | ||
``airflow users create`` command will be able to pass the API authentication. | ||
|
||
Roll your own API authentication | ||
'''''''''''''''''''''''''''''''' | ||
|
||
Each auth backend is defined as a new Python module. It must have 2 defined methods: | ||
|
||
* ``init_app(app: Flask)`` - function invoked when creating a flask application, which allows you to add a new view. | ||
* ``requires_authentication(fn: Callable)`` - a decorator that allows arbitrary code execution before and after or instead of a view function. | ||
|
||
and may have one of the following to support API client authorizations used by :ref:`remote mode for CLI <cli-remote>`: | ||
|
||
* function ``create_client_session() -> requests.Session`` | ||
* attribute ``CLIENT_AUTH: tuple[str, str] | requests.auth.AuthBase | None`` | ||
|
||
After writing your backend module, provide the fully qualified module name in the ``auth_backends`` key in the ``[api]`` | ||
section of ``airflow.cfg``. | ||
|
||
Additional options to your auth backend can be configured in ``airflow.cfg``, as a new option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section has been moved from
security/api.rst