3
votes

Apache Airflow REST API fails with 403 forbidden for the call:

"/api/experimental/test"

Configuration in airflow.cfg

[webserver]

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

[api]

  • rbac = True
  • auth_backend = airflow.contrib.auth.backends.password_auth

After setting all this, docker image is built and run as a docker container.

Created the airflow user as follows:

airflow create_user -r Admin -u admin -e [email protected] -f Administrator -l 1 -p admin

Login with credentials for Web UI works fine.

Where as login to REST API is not working. HTTP Header for authentication: Authorization BASIC YWRtaW46YWRtaW4=

Airflow version: 1.10.9

1

1 Answers

7
votes

By creating user in the following manner we can access the Airflow experimental API using credentials.

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

By creating user with "airflow create_user" command, we cannot access the Airflow Experimental APIs.