You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "AutomationDev85 (via GitHub)" <gi...@apache.org> on 2024/12/06 13:56:00 UTC

[PR] [Edge] Fix edge worker api support none default base api url [airflow]

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

   # Description
   
   If Airflow deployment runs on none default base url the Edge worker api auth fails. The Edge worker api auth compares the method names which include  the url path. But auth does not know on which sub url it is running. Auth detects a mismatch and blocks the request.
   
   # Details about changes
   * Edge worker uses pure method name (url path without base url)
   * Edge worker api auth compares method name without using the url_prefix


-- 
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] [Edge] Fix edge worker api support none default base api url [airflow]

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


-- 
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] [Edge] Fix edge worker api support none default base api url [airflow]

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


##########
providers/src/airflow/providers/edge/CHANGELOG.rst:
##########
@@ -27,6 +27,14 @@
 Changelog
 ---------
 
+0.9.2pre0
+.........
+
+Misc
+~~~~
+
+* ``Fix check api call with different root url.``

Review Comment:
   ```suggestion
   * ``Fix check edge worker api call authentication with different base url. Authentication failed when Airflow is not installed in webserver root.``
   ```



-- 
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] [Edge] Fix edge worker api support none default base api url [airflow]

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


##########
providers/src/airflow/providers/edge/worker_api/auth.py:
##########
@@ -66,13 +66,19 @@ def _forbidden_response(message: str):
 def jwt_token_authorization(method: str, authorization: str):
     """Check if the JWT token is correct."""
     try:
+        # worker sends method without api_url
+        api_url = conf.get("edge", "api_url")
+        base_url = conf.get("webserver", "base_url")
+        url_prefix = api_url.replace(base_url, "").replace("/rpcapi", "")
+        pure_method = method.replace(url_prefix, "")
+        pure_method = pure_method[1:]

Review Comment:
   The token authentication is (for Airflow 2.10) used for both API calls of Edge Worker as well as AIP-44 RPCAPI. With this change the EdgeWorker can call the API _but_ calls to RPCAPI are broken. When a task starts it fails with:
   ```
   [2024-12-06T21:21:03.181+0000] {auth.py:59} ERROR - Invalid method in token authorization. signed method='airflow.utils.cli_action_loggers._default_action_log_internal' called method='irflow.utils.cli_action_loggers._default_action_log_internal' error_id=c84e8a0a-6114-4fcf-8888-90dc150ce6b3
   ```
   
   So maybe it would be better to make it like:
   ```suggestion
           url_prefix = api_url.replace(base_url, "").replace("/rpcapi", "/")
           pure_method = method.replace(url_prefix, "")
   ```



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