fat-catTW commented on code in PR #77138:
URL: https://github.com/apache/airflow/pull/77138#discussion_r4587242668
##########
providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -183,6 +185,31 @@
}
CACHE_TTL = conf.getint("fab", "cache_ttl", fallback=30)
+# A token is accepted only while this claim matches the user's current
password fingerprint.
+PASSWORD_FINGERPRINT_CLAIM = "password_fingerprint"
+PASSWORD_FINGERPRINT_HEX_LENGTH = 32
+
+
+def _compute_password_fingerprint(user: User | AnonymousUser) -> str:
+ """
+ Return a fingerprint of the user's current password.
+
+ It changes whenever the password is changed or reset. Users without a
local password share a
+ constant fingerprint.
+ """
+ password_hash = getattr(user, "password", None) or ""
+ return hmac.new(
+ conf.get_mandatory_value("api", "secret_key").encode(),
+ f"airflow.fab.password-fingerprint:{password_hash}".encode(),
Review Comment:
I agree.
It uses the existing password hash only as input to a keyed change
fingerprint, not for password storage or verification. A slow password hash
would add per-request cost without improving this use case, so this looks like
a CodeQL false positive to me.
--
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]