settings: Make AVATAR_SALT mandatory.

This also allows us to remove some assertions as we now know that
AVATAR_SALT will never be None.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-08-23 19:44:43 -04:00
committed by Tim Abbott
parent 059d0e7be8
commit c8d5959689
3 changed files with 1 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ def user_avatar_hash(uid: str) -> str:
# The salt probably doesn't serve any purpose now. In the past we
# used a hash of the email address, not the user ID, and we salted
# it in order to make the hashing scheme different from Gravatar's.
assert settings.AVATAR_SALT is not None
user_key = uid + settings.AVATAR_SALT
return make_safe_digest(user_key, hashlib.sha1)

View File

@@ -19,7 +19,6 @@ from zerver.models import UserProfile
# since we rearranged the avatars in Zulip 1.6.
def patched_user_avatar_path(user_profile: UserProfile) -> str:
email = user_profile.email
assert settings.AVATAR_SALT is not None
user_key = email.lower() + settings.AVATAR_SALT
return make_safe_digest(user_key, hashlib.sha1)

View File

@@ -82,7 +82,7 @@ SHARED_SECRET = get_mandatory_secret("shared_secret")
# avatar. If this salt is discovered, attackers will only be able to determine
# that the owner of an email account has uploaded an avatar to Zulip, which isn't
# the end of the world. Don't use the salt where there is more security exposure.
AVATAR_SALT = get_secret("avatar_salt")
AVATAR_SALT = get_mandatory_secret("avatar_salt")
# SERVER_GENERATION is used to track whether the server has been
# restarted for triggering browser clients to reload.