aws / amazon-mwaa-docker-images

Apache License 2.0
27 stars 11 forks source link

feat: add option for no auth #71

Closed agupta01 closed 5 months ago

agupta01 commented 5 months ago

Description of changes:

This adds the ability to disable authentication in the local runner. (NOTE: this should only be used in non-production environments).

Usage

In order to fully disable auth:

  1. Set MWAA__CORE__AUTH_TYPE to "none"
  2. Add '{"auth_backends": "airflow.api.auth.backend.default"}' to MWAA__CORE__CUSTOM_AIRFLOW_CONFIGS

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

rafidka commented 5 months ago

Add '{"auth_backends": "airflow.api.auth.backend.default"}' to MWAA__CORE__CUSTOM_AIRFLOW_CONFIGS

We should add this environment variable ourselves, instead of expecting the user to set the auth type to none, and then manually set the auth backend.

Also, I assume you meant AIRFLOW__API__AUTH_BACKENDS config, right? If that's the case, then basically you need to add a function for the API configuration in this file, something like:

def _get_essential_airflow_api_config() -> Dict[str, str]:
  api_config = {}
  if os.environ.get("MWAA__CORE__AUTH_TYPE", "").lower() == "none":
      api_config["AIRFLOW__API__AUTH_BACKENDS"] =  "airflow.api.auth.backend.default"

  return api_config
agupta01 commented 5 months ago

@rafidka Thanks for the feedback — I agree, user setting MWAA__CORE__CUSTOM_AIRFLOW_CONFIGS="none" should be all they need to do to disable auth. I made the proposed change of moving the config to airflow.py and tested it.