Roles and Permissions

Apache Airflow provides a robust Role-Based Access Control (RBAC) system that allows you to define granular permissions for different users and groups. This ensures that users can only access and perform actions that are appropriate for their roles.

Core Concepts

Default Roles

Airflow comes with a few default roles:

Permission Model

The Airflow permission model uses a structure of <action> on <resource_type>. For instance:

Resource Specificity

Permissions can be applied globally or to specific resources. For example:

Managing Roles and Permissions

You can manage roles and permissions through the Airflow UI or programmatically:

Via the Airflow UI

  1. Navigate to the Security section in the Airflow UI.
  2. Click on Roles to view, create, or edit roles.
  3. When editing a role, you can add or remove permissions from the available list. You can also specify resource-specific permissions.
  4. Click on Users to manage users and assign them to roles.
Note: Resource-specific permissions require the resource to exist before the permission can be granted.

Via the Command Line Interface (CLI)

The Airflow CLI can be used for managing roles and permissions. For example:


airflow users create --username admin --firstname Admin --lastname User --role Admin --email admin@example.com
airflow roles create --name MyCustomRole
airflow permissions add --role MyCustomRole --permission can_read --resource DAG
airflow permissions add --role MyCustomRole --permission can_edit --resource DAG --dag_id my_specific_dag
            

Permission Types and Resources

Here's a non-exhaustive list of common permissions and their associated resources:

DAGs

Task Instances

Connections

Variables

Pools

Tip: For a complete and up-to-date list of all available permissions and resources, refer to the Airflow source code or the Airflow UI's role management section.

Best Practices