In this example we will see how we apply security in airflow basically what we want to do is user should only have access of their own dags and they should not have the access of others dags
Let’s create a very simple
from airflow import DAG from airflow.operators.bash_operator import BashOperator from datetime import datetime,timedelta default_args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(2023, 12, 13), 'email_on_failure': False, 'email_on_retry': False, 'retries': 1, 'retry_delay': timedelta(minutes=5), } dag = DAG( 'pass_param', default_args=default_args, schedule_interval=None, ) t1 = BashOperator( task_id='print_hello', bash_command='echo "Hello, {{ dag_run.conf["name"] }}"', dag=dag, ) t1
- Now we need to create the user in airflow we can using the UI of the airflow.
- Now let’s create the role Navigate to Security then List Roles click on + icon and create the role this will be custom role.
- We can create this role as single_dag_access and at the end we can choose which dags which we want to show using this role.
- Now the last step is assign this role to the our user.
- Now login and verify if our changes has been applied or not.
As you can see the above screenshot now our user only have access of one dag only.
We at Helical have more than 10 years of experience in providing solutions and services in the domain of data and have served more than 85+ clients. Please reach out to us for assistance, consulting, services, maintenance as well as POC and to hear about our past experience on Airflow. Please do reach out on nikhilesh@Helicaltech.com
Thank You
Abhishek Mishra
Helical IT Solutions
Subscribe
Login
0 Comments