You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2025/04/07 21:03:10 UTC

[PR] Apply configuration defined in `webserver_config.py` to Flask config [airflow]

vincbeck opened a new pull request, #48898:
URL: https://github.com/apache/airflow/pull/48898

   In AF2 you can extend the Flask application configuration in `$AIRFLOW_HOME/webserver_config.py`. We must keep this mechanism in FAB provider in AF3 because many users rely on it (and some features as well). The [documentation](https://github.com/apache/airflow/blob/providers-fab/2.0.0rc3/providers/fab/docs/auth-manager/webserver-authentication.rst) refers to this file as well. This is an issue reported by @zachliu on [Slack](https://apache-airflow.slack.com/archives/C07813CNKA8/p1744051444881319).
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply configuration defined in `webserver_config.py` to Flask config [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #48898:
URL: https://github.com/apache/airflow/pull/48898#issuecomment-2786222261

   nice!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply configuration defined in `webserver_config.py` to Flask config [airflow]

Posted by "zachliu (via GitHub)" <gi...@apache.org>.
zachliu commented on PR #48898:
URL: https://github.com/apache/airflow/pull/48898#issuecomment-2786674859

   Here’s a summary of the issue (Slack messages only have a 90-day lifespan):
   
   * Airflow version: `3.0.0rc1.post2`, providers-fab version: `2.0.0rc3`
   * `airflow.cfg` contains:
       ```ini
       [core]
       auth_manager = airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager
   
       [fab]
       auth_backends = airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.providers.fab.auth_manager.api.auth.backend.session
       ```
   * symptom: the OAuth login page does not load
   ![2025-04-07_14-41](https://github.com/user-attachments/assets/4025ef10-2819-4530-8d76-cb6dea8a9eea)
   
   * `webserver_config.py` is set up following [FAB documentation](https://github.com/apache/airflow/blob/providers-fab/2.0.0rc3/providers/fab/docs/auth-manager/webserver-authentication.rst):
       ```python
       from __future__ import annotations
   
       import os
       
       from airflow.providers.fab.auth_manager.security_manager.override import (
           FabAirflowSecurityManagerOverride,
       )
       from flask_appbuilder.const import AUTH_OAUTH
       
       # Flask-WTF flag for CSRF
       WTF_CSRF_ENABLED = True
       WTF_CSRF_TIME_LIMIT = None
       
       AUTH_TYPE = AUTH_OAUTH
       AUTH_USER_REGISTRATION = True
       AUTH_USER_REGISTRATION_ROLE = None
       AUTH_ROLES_SYNC_AT_LOGIN = True
       
       OAUTH_PROVIDERS = [
           {
               'name': 'auth0',
               ...
           },
       ]
       
       class CustomSecurityManager(FabAirflowSecurityManagerOverride):
           """Custom Security Manager"""
       
       SECURITY_MANAGER_CLASS = CustomSecurityManager
       ```
   
   * Confusing log entry observed:
       ```
       webserver-1  | [2025-04-07T20:07:23.995+0000] {override.py:824} DEBUG - OAuth providers init auth0
       ```
   
   Solution:
   * Fixed in this PR - thanks to @vincbeck :tada: 
   * That log entry showed up because we had all run `airflow users create ...` at some point, which invokes https://github.com/apache/airflow/blob/adbb062b50e2e128fe475a76b7ce10ec93c39ee2/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/utils.py#L57
   but it doesn’t actually use the "flask_app" object in the ways that matter for OAuth.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply configuration defined in `webserver_config.py` to Flask config [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #48898:
URL: https://github.com/apache/airflow/pull/48898


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org