You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/10/20 14:06:27 UTC

[PR] Upgrade to Flask Application Builder 4.3.9 [airflow]

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

   This PR brings all the necessary changes to upgrade to FAB 4.3.9 from 4.3.6.
   
   It incorporates those changes:
   
   * https://github.com/dpgaspar/Flask-AppBuilder/pull/2112
   * https://github.com/dpgaspar/Flask-AppBuilder/pull/2121
   
   It also removes the limitation of the WTForms after compatibility has been implemented:
   
   * https://github.com/dpgaspar/Flask-AppBuilder/pull/2138
   
   <!--
    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.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 [newsfragments](https://github.com/apache/airflow/tree/main/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] Upgrade to Flask Application Builder 4.3.9 [airflow]

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

   Well. Just changed it to 2.8.0. It won't make it to 2.7.3 because we have quite heavy refactor for AIP-58 and we won't be able to cherry-pick this change cleanly. Sorry for that :(


-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "jens-scheffler-bosch (via GitHub)" <gi...@apache.org>.
jens-scheffler-bosch commented on PR #35085:
URL: https://github.com/apache/airflow/pull/35085#issuecomment-1773898293

   2.8.0 is also okay. We have (for our setup) no dependency. No pressure from my side.


-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

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

   Due to a tight integration and override, that one would require  a bit careful review and double-checking whether all the changes 4.3.6 -> 4.3.9 


-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35085:
URL: https://github.com/apache/airflow/pull/35085#discussion_r1411379983


##########
airflow/auth/managers/fab/security_manager/override.py:
##########
@@ -1432,23 +1430,14 @@ def get_oauth_user_info(self, provider, resp):
                 "last_name": data.get("family_name", ""),
                 "email": data.get("email", ""),
             }
-        # for Azure AD Tenant. Azure OAuth response contains
-        # JWT token which has user info.
-        # JWT token needs to be base64 decoded.
-        # https://docs.microsoft.com/en-us/azure/active-directory/develop/
-        # active-directory-protocols-oauth-code
         if provider == "azure":
-            log.debug("Azure response received : %s", resp)
-            id_token = resp["id_token"]
-            log.debug(str(id_token))
-            me = self._azure_jwt_token_parse(id_token)
-            log.debug("Parse JWT token : %s", me)
+            me = self._decode_and_validate_azure_jwt(resp["id_token"])
+            log.debug("User info from Azure: %s", me)
+            # https://learn.microsoft.com/en-us/azure/active-directory/develop/id-token-claims-reference#payload-claims
             return {
-                "name": me.get("name", ""),
-                "email": me["upn"],
+                "email": me["email"],

Review Comment:
   Merged in https://github.com/apache/airflow/pull/35991 -> will be released in 2.8.0



-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "jens-scheffler-bosch (via GitHub)" <gi...@apache.org>.
jens-scheffler-bosch commented on PR #35085:
URL: https://github.com/apache/airflow/pull/35085#issuecomment-1773840832

   FYI @wolfdn Your fix is going to be integrated in 2.7.3 :-D


-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

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

   Rebased and resolved conflicts after @vincbeck's merged #34924


-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35085:
URL: https://github.com/apache/airflow/pull/35085#discussion_r1410905233


##########
airflow/auth/managers/fab/security_manager/override.py:
##########
@@ -1432,23 +1430,14 @@ def get_oauth_user_info(self, provider, resp):
                 "last_name": data.get("family_name", ""),
                 "email": data.get("email", ""),
             }
-        # for Azure AD Tenant. Azure OAuth response contains
-        # JWT token which has user info.
-        # JWT token needs to be base64 decoded.
-        # https://docs.microsoft.com/en-us/azure/active-directory/develop/
-        # active-directory-protocols-oauth-code
         if provider == "azure":
-            log.debug("Azure response received : %s", resp)
-            id_token = resp["id_token"]
-            log.debug(str(id_token))
-            me = self._azure_jwt_token_parse(id_token)
-            log.debug("Parse JWT token : %s", me)
+            me = self._decode_and_validate_azure_jwt(resp["id_token"])
+            log.debug("User info from Azure: %s", me)
+            # https://learn.microsoft.com/en-us/azure/active-directory/develop/id-token-claims-reference#payload-claims
             return {
-                "name": me.get("name", ""),
-                "email": me["upn"],
+                "email": me["email"],

Review Comment:
   Well. This has been straight copied from FAB 4.3.9  - unless I made a mistake of course. We don't even analyse that we are just making sure that we have the same code as the original FAB Securiy Manager Has.
   
   So if there is any problem with it - it should rather be raised to FAB not to us - our change is simply a `direct`  pass-through to FAB.
   
   However this is a very valid point - I see that last week FAB released version 4.3.10 which contains this one: https://github.com/dpgaspar/Flask-AppBuilder/pull/2163   which solves precisely the problem you mention.
   
   So ... time to upgrade to 4.3.10 it seems.



-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35085:
URL: https://github.com/apache/airflow/pull/35085#discussion_r1410905233


##########
airflow/auth/managers/fab/security_manager/override.py:
##########
@@ -1432,23 +1430,14 @@ def get_oauth_user_info(self, provider, resp):
                 "last_name": data.get("family_name", ""),
                 "email": data.get("email", ""),
             }
-        # for Azure AD Tenant. Azure OAuth response contains
-        # JWT token which has user info.
-        # JWT token needs to be base64 decoded.
-        # https://docs.microsoft.com/en-us/azure/active-directory/develop/
-        # active-directory-protocols-oauth-code
         if provider == "azure":
-            log.debug("Azure response received : %s", resp)
-            id_token = resp["id_token"]
-            log.debug(str(id_token))
-            me = self._azure_jwt_token_parse(id_token)
-            log.debug("Parse JWT token : %s", me)
+            me = self._decode_and_validate_azure_jwt(resp["id_token"])
+            log.debug("User info from Azure: %s", me)
+            # https://learn.microsoft.com/en-us/azure/active-directory/develop/id-token-claims-reference#payload-claims
             return {
-                "name": me.get("name", ""),
-                "email": me["upn"],
+                "email": me["email"],

Review Comment:
   Well. This has been straight copied from FAB 4.3.9  - unless I made a mistake of course. We don't even analyse that we are just making sure that we have the same code as the original FAB Securiy Manager Has.
   
   So if there is any problem with it - it should rather be raised to FAB not to us - our change is simply a `direct`  pass-through to FAB.
   
   However this is a very valid point - I see that last week FAB released version 4.3.10 which contains this one: https://github.com/dpgaspar/Flask-AppBuilder/pull/2163   which solves precisely the problem you mention.
   
   So ... time to upgradfe to 4.3.10 it seems.



-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

Posted by "hterik (via GitHub)" <gi...@apache.org>.
hterik commented on code in PR #35085:
URL: https://github.com/apache/airflow/pull/35085#discussion_r1410850196


##########
airflow/auth/managers/fab/security_manager/override.py:
##########
@@ -1432,23 +1430,14 @@ def get_oauth_user_info(self, provider, resp):
                 "last_name": data.get("family_name", ""),
                 "email": data.get("email", ""),
             }
-        # for Azure AD Tenant. Azure OAuth response contains
-        # JWT token which has user info.
-        # JWT token needs to be base64 decoded.
-        # https://docs.microsoft.com/en-us/azure/active-directory/develop/
-        # active-directory-protocols-oauth-code
         if provider == "azure":
-            log.debug("Azure response received : %s", resp)
-            id_token = resp["id_token"]
-            log.debug(str(id_token))
-            me = self._azure_jwt_token_parse(id_token)
-            log.debug("Parse JWT token : %s", me)
+            me = self._decode_and_validate_azure_jwt(resp["id_token"])
+            log.debug("User info from Azure: %s", me)
+            # https://learn.microsoft.com/en-us/azure/active-directory/develop/id-token-claims-reference#payload-claims
             return {
-                "name": me.get("name", ""),
-                "email": me["upn"],
+                "email": me["email"],

Review Comment:
   Is this correct? After pulling latest main, this fails. Even if `email` is included in the scope claims it's not returned in the token, `upn` is included as before. (This could of course be an integration issue with the IDP on our end)
   
   Either way, remember to include this in the release notes, because it may require updated scope in the webserver_config by the administrator.



-- 
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] Upgrade to Flask Application Builder 4.3.9 [airflow]

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


-- 
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