Force use of symetric JWT algorithm for internal logs server#49029
Merged
Conversation
Since the logs server was hard-coded to use a secret_key, if a user specified
the `api_auth`.`jwt_algorithm` config section it would have interferred and
caused this error:
```
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/airflow/utils/log/file_task_handler.py", line 567, in _read_from_logs_server
response = _fetch_logs_from_service(url, rel_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/airflow/utils/log/file_task_handler.py", line 112, in _fetch_logs_from_service
headers={"Authorization": generator.generate({"filename": log_relative_path})},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/airflow/api_fastapi/auth/tokens.py", line 458, in generate
return jwt.encode(claims, self.signing_arg, algorithm=self.algorithm, headers=headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jwt/api_jwt.py", line 78, in encode
return api_jws.encode(
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jwt/api_jws.py", line 170, in encode
key = alg_obj.prepare_key(key)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jwt/algorithms.py", line 738, in prepare_key
raise InvalidKeyError(
jwt.exceptions.InvalidKeyError: Expecting a EllipticCurvePrivateKey/EllipticCurvePublicKey. Wrong key provided for EdDSA algorithms
```
The fix is to force a use of HS512 (the same one you would get if you didn't
specify an algorithm and did pass just a secret_key)
Fixes apache#48759
dstandish
approved these changes
Apr 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the logs server was hard-coded to use a secret_key, if a user specified
the
api_auth.jwt_algorithmconfig section it would have interferred andcaused this error:
The fix is to force a use of HS512 (the same one you would get if you didn't
specify an algorithm and did pass just a secret_key)
Fixes #48759
(See also #49028 though)