sjyangkevin commented on code in PR #77138:
URL: https://github.com/apache/airflow/pull/77138#discussion_r4580612649


##########
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:
   Some thoughts on this, but would appreciate for feedback.
   
   The input is the stored password hash (already computed by FAB), not the 
plain password. The HMAC-SHA256 output is only used as a fingerprint to detect 
when that stored hash changes, and is never used to store or verify passwords; 
login still verifies passwords through FAB's scrypt check. A slow hash here 
would add cost to every API request.



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

Reply via email to