Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate authentication in Apache Airflow

Airflow version- 1.9.0

I have installed apache airflow and post configuration i am able to run sample DAG's with sequential executor.

Also, created new sample user which i can see under Admin > Users.

But unable to get the login window/screen when we visit webserver adress at :8080/ it directly opens up Airflow webserver with admin user. It will be great help if anyone can provide some info on how to activate login screen/page, so that user credentials can be used for logging into webserver.

Steps followed to enable web user authentication: https://airflow.apache.org/security.html?highlight=authentication

like image 924
AshishPatil Avatar asked Aug 28 '18 11:08

AshishPatil


People also ask

How do I enable SSL on Airflow?

SSL can be enabled by providing a certificate and key. Once enabled, be sure to use “https://” in your browser. Enabling SSL will not automatically change the web server port. If you want to use the standard port 443, you'll need to configure that too.

What is Airflow username and password?

default credentials -- user: admin - password: admin. How to create airflow users?


3 Answers

Check the following in your airflow.cfg file:

[webserver]
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

And also remember to Restart Airflow Webserver, if it still doesn't work, run airflow initdb and restart the webserver.

Also, double-check in airflow.cfg file that it does not contain multiple configurations for authenticate or auth_backend. If there is more than one occurrence, than it can cause that issue.

If necessary, install flask_bcrpyt package of python2.x/3.x For instance, $ python3.7 -m pip install flask_bcrypt

Make sure you have an admin user created,

airflow create_user -r Admin -u admin -e [email protected] -f admin -l user -p *****
like image 87
kaxil Avatar answered Nov 01 '22 00:11

kaxil


  1. edit airflow.cfg
    inside [webserver] section

    • change authenticate = True. by default it is set to False.
    • add auth_backend = airflow.contrib.auth.backends.password_auth.
    • change rbac = True for Role-based-access-control – RBAC.
  2. airflow initdb

  3. restart airflow webserver
like image 45
Ganesh Avatar answered Nov 01 '22 02:11

Ganesh


just add rbac = True to airflow.cfg, and you are good to go. Now all you need to is restart your airflow webserver. And in case if you want to add a new user. You can use this command,

 airflow create_user -r Admin -u admin -f Ashish -l malgawa -p test123 -e [email protected]

“-r” is the role we want for the user “-u” is the username “-f” is the first name “-l” is the last name “-e” is the email id “-p” is the password

For more details, you can follow this article https://www.cloudwalker.io/2020/03/01/airflow-rbac-role-based-access-control/#:~:text=RBAC%20is%20the%20quickest%20way,access%20to%20DAGs%20as%20well

like image 45
ashish malgawa Avatar answered Nov 01 '22 02:11

ashish malgawa