Apache Airflow FAB Provider

3.6.0 · active · verified Sun Mar 29

The Apache Airflow FAB (Flask AppBuilder) Provider package integrates Flask-AppBuilder functionalities into Apache Airflow, primarily enhancing its User Interface (UI) and Role-Based Access Control (RBAC) capabilities. It is an actively maintained provider, with the current version being 3.6.0. New versions are released independently of core Airflow, following a strict SemVer policy, and can introduce database migrations.

Warnings

Install

Imports

Quickstart

This provider primarily extends Airflow's UI and RBAC. A common interaction is through Airflow's CLI for user management, which leverages the Flask AppBuilder backend provided by this package. For advanced authentication methods like OAuth/SSO, customization of `webserver_config.py` is required.

# This provider enhances Airflow's UI/RBAC; direct code interaction is mostly via Airflow CLI or configuration.
# Ensure Airflow is running with this provider installed.
# Example: Creating a user via Airflow CLI (which uses the FAB backend):
# Make sure to run this command in your Airflow environment where `apache-airflow-providers-fab` is installed.
# Replace sensitive details with environment variables in a production setup.

import os

# Example of setting up environment variables for a new user
# In a real scenario, you'd execute this via command line or a script,
# not directly in a Python quickstart meant for direct execution.
# For demonstration, assume these are set or replaced by actual values.
admin_username = os.environ.get('AIRFLOW_ADMIN_USERNAME', 'admin')
admin_firstname = os.environ.get('AIRFLOW_ADMIN_FIRSTNAME', 'Airflow')
admin_lastname = os.environ.get('AIRFLOW_ADMIN_LASTNAME', 'User')
admin_role = os.environ.get('AIRFLOW_ADMIN_ROLE', 'Admin')
admin_email = os.environ.get('AIRFLOW_ADMIN_EMAIL', 'admin@example.com')
admin_password = os.environ.get('AIRFLOW_ADMIN_PASSWORD', 'supersecretpassword')

# This command would typically be run in your shell:
# airflow users create \
#     -u "${AIRFLOW_ADMIN_USERNAME}" \
#     -f "${AIRFLOW_ADMIN_FIRSTNAME}" \
#     -l "${AIRFLOW_ADMIN_LASTNAME}" \
#     -r "${AIRFLOW_ADMIN_ROLE}" \
#     -e "${AIRFLOW_ADMIN_EMAIL}" \
#     -p "${AIRFLOW_ADMIN_PASSWORD}"

print(f"To create an Airflow user via CLI (using FAB provider's backend), run:\n")
print(f"airflow users create -u {admin_username} -f {admin_firstname} -l {admin_lastname} -r {admin_role} -e {admin_email} -p {admin_password}")
print(f"\nFor advanced authentication (e.g., OAuth), configure `webserver_config.py` as described in Airflow documentation.")

view raw JSON →