kaxil commented on code in PR #77814:
URL: https://github.com/apache/airflow/pull/77814#discussion_r4746736734
##########
airflow-core/src/airflow/configuration.py:
##########
@@ -643,7 +643,7 @@ def write_default_airflow_configuration_if_needed() ->
AirflowConfigParser:
)
conf._default_values.set("core", "fernet_key",
_SecretKeys.fernet_key)
- _SecretKeys.jwt_secret_key = b64encode(os.urandom(16)).decode("utf-8")
+ _SecretKeys.jwt_secret_key = b64encode(os.urandom(48)).decode("utf-8")
Review Comment:
`SECRET_KEY` at line 836 is still `b64encode(os.urandom(16))`, and it's the
default for `[api] secret_key`, which signs the log server tokens with HS512
(`file_task_handler.py` and `log_server.py`). So fetching logs of a running
task from a worker's log server still warns on a default install. Could all
four sites go through one helper next to `_generate_fernet_key()`, so the 48 is
explained once? Breeze's `shell_params.py`, the chart's `api-secret-key` (and
the `token_hex(16)` in its production guide), and the Docker Compose default
`airflow_jwt_secret` give short keys too, but those are fine as follow-ups.
##########
airflow-core/src/airflow/api_fastapi/auth/tokens.py:
##########
@@ -570,7 +570,7 @@ def get_signing_key(section: str, key: str,
make_secret_key_if_needed: bool = Tr
section,
key,
)
- secret_key = base64url_encode(os.urandom(16))
+ secret_key = base64url_encode(os.urandom(48))
Review Comment:
`security/jwt_token_authentication.rst` still says Airflow auto-generates a
random 16-byte key here. Can you update it to 48 in this PR?
##########
airflow-core/newsfragments/77805.bugfix.rst:
##########
@@ -0,0 +1 @@
+Increase generated JWT secrets to 64 characters to avoid short HMAC key
warnings with HS512.
Review Comment:
Could you drop this newsfragment? airflow-core only takes `significant`
fragments now (see `contributing-docs/18_contribution_workflow.rst`), and the
release notes for a bug fix come from the commit title. It's also named after
the issue rather than the PR, which the newsfragment check rejects.
##########
airflow-core/tests/unit/api_fastapi/auth/test_tokens.py:
##########
@@ -136,6 +137,13 @@ def test_with_secret_key():
assert generator.signing_arg == "abc"
+async def test_get_signing_key_generates_secret():
Review Comment:
Nothing is awaited here, so this can be a plain `def` like
`test_with_secret_key` above.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]