from airflow import DAG
from airflow.operators.dummy import DummyOperator
from datetime import datetime, timedelta
# Default arguments to be used in the DAG
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2023, 1, 1),
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
# Define the DAG with access control
dag = DAG(
'test_access_control',
default_args=default_args,
description='An example DAG with access control',
schedule_interval=None,
access_control={
'User': {"can_edit", "can_read"},
}
)
# Define tasks in the DAG
start = DummyOperator(
task_id='start',
dag=dag,
)
end = DummyOperator(
task_id='end',
dag=dag,
)
# Set the task dependencies
start >> end
일단 기본적인 샘플 코드다.
다음은
Airflow Web UI > Security > List Roles > User 체크 후 상단 Actions의 Copy Role 을 진행한 후
Copy Role에서 이름 변경, can read on DAGs, can edit on DAGs 역할 제거 후 Save

그럼 이렇게 만들어졌다.
dag = DAG(
'test_access_control1',
default_args=default_args,
description='An example DAG with access control',
schedule_interval=None,
access_control={
'project_A': {"can_edit", "can_read"}
}
이 부분만 수정해준다.