Only create initial passwords for local dev setups

(imported from commit 2ef33ebbab0fe21486acbb1a3a78ed434abac2db)
This commit is contained in:
Leo Franchi
2013-11-12 12:20:05 -05:00
committed by Tim Abbott
parent d7b823f017
commit 306ce65ea3
4 changed files with 25 additions and 20 deletions

View File

@@ -30,8 +30,8 @@ def create_user_profile(realm, email, password, active, bot, full_name, short_na
onboarding_steps=ujson.dumps([]))
if bot or not active:
user_profile.set_unusable_password()
else:
password = None
user_profile.set_password(password)
user_profile.api_key = random_api_key()

View File

@@ -9,5 +9,9 @@ def initial_password(email):
"""Given an email address, returns the initial password for that account, as
created by populate_db."""
if settings.INITIAL_PASSWORD_SALT is not None:
digest = hashlib.sha256(settings.INITIAL_PASSWORD_SALT + email).digest()
return base64.b64encode(digest)[:16]
else:
# None as a password for a user tells Django to set an unusable password
return None

View File

@@ -1,8 +1,19 @@
# Secret Django settings for the Zulip project
import os
import platform
import ConfigParser
config_file = ConfigParser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")
# Whether we're running in a production environment. Note that DEPLOYED does
# **not** mean hosted by us; customer sites are DEPLOYED and ENTERPRISE
# and as such should not for example assume they are the main Zulip site.
DEPLOYED = config_file.has_option('machine', 'deploy_type')
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
ENTERPRISE = DEPLOYED and config_file.get('machine', 'deploy_type') == 'enterprise'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@@ -17,7 +28,8 @@ HASH_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
AVATAR_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# Used just for generating initial passwords (only used in testing environments).
INITIAL_PASSWORD_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
if not DEPLOYED:
INITIAL_PASSWORD_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# A shared secret, used to authenticate different parts of the app to each other.
# FIXME: store this password more securely
@@ -45,18 +57,6 @@ EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxxxxx'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
config_file = ConfigParser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")
# Whether we're running in a production environment. Note that DEPLOYED does
# **not** mean hosted by us; customer sites are DEPLOYED and ENTERPRISE
# and as such should not for example assume they are the main Zulip site.
DEPLOYED = config_file.has_option('machine', 'deploy_type')
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
ENTERPRISE = DEPLOYED and config_file.get('machine', 'deploy_type') == 'enterprise'
SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer"
if TESTING_DEPLOYED:

View File

@@ -257,7 +257,8 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
'NAGIOS_STAGING_SEND_BOT': None,
'NAGIOS_STAGING_RECEIVE_BOT': None,
'APNS_CERT_FILE': None,
'ZULIP_ADMINISTRATOR': ''
'ZULIP_ADMINISTRATOR': '',
'INITIAL_PASSWORD_SALT': None
}
for setting_name, setting_val in DEFAULT_SETTINGS.iteritems():