[PYTHON] Create user authentication function in Airflow

The authentication function is not turned on in airflow with the default webserver setting. Although there is no operational access from the outside, I want to add it! I think there are people who say that, so that method. Or rather, the basics are written in the document, so if you look here you can do everything. https://pythonhosted.org/airflow/security.html

There are LDAP and GHE, but this time the most basic email, pass

Advance preparation

First of all, you need flask_bcrypt to use authentication, so install it

pip install flask_bcrypt

After that, you should be able to handle it with the standard one

Changes to airflow.cfg

Since ʻauthenticate` is initially False, comment it out or set it to True.

authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

Create user

Create a user from the command line.

Open the console with the python command, change the following user information, and press Enter to complete user creation.

import airflow
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
user = PasswordUser(models.User())
user.username = '[Any username]'
user.email = '[Any email address]'
user.password = '[Any password]'
session = settings.Session()
session.add(user)
session.commit()
session.close()
exit()

If you restart the web server with this, the following screen should be displayed

スクリーンショット.png

Finally

It seems that you can't set the permissions. ??

Recommended Posts

Create user authentication function in Airflow
Create a function in Python
Duality in function
Execute function in parallel
Generator function in JavaScript
Create SpatiaLite in Python
Creating an authentication function
Create APIs around user authentication with Django REST Framework
Easily create authentication, user management, and multilingual systems with Flask-AppBuilder
Create an authentication feature with django-allauth and CustomUser in Django
Let's create a function to hold down Button in Tkinter
Covector to think in function
Create a dictionary in Python
Use callback function in Python
ntile (decile) function in python
Create gif video in Python
Implement timer function in pygame
Parse User Agent in Python
Nonlinear function modeling in Python
Draw implicit function in python
Immediate function in python (lie)
Create Cognito user list in S3 with SQS Deploy queue function and API to Lambda with SAM
Create a function to get the contents of the database in Go