Move all remaining calls of get_secret from local_settings.py to settings.py.

(imported from commit 099a122121f8e06568cef3579f955cb73b20ee50)
This commit is contained in:
Yoyo Zhou
2015-08-20 22:12:15 -07:00
parent bd5fc484f0
commit 15abf9ed31
2 changed files with 20 additions and 17 deletions

View File

@@ -15,26 +15,10 @@ TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'te
ENTERPRISE = DEPLOYED and config_file.get('machine', 'deploy_type') == 'enterprise'
secrets_file = ConfigParser.RawConfigParser()
if DEPLOYED:
secrets_file.read("/etc/zulip/zulip-secrets.conf")
else:
secrets_file.read("zproject/dev-secrets.conf")
def get_secret(key):
if secrets_file.has_option('secrets', key):
return secrets_file.get('secrets', key)
return None
MAILCHIMP_API_KEY = get_secret("mailchimp_api_key")
ZULIP_FRIENDS_LIST_ID = '84b2f3da6b'
# This can be filled in automatically from the database, maybe
DEPLOYMENT_ROLE_NAME = 'zulip.com'
DEPLOYMENT_ROLE_KEY = get_secret("deployment_role_key")
# This comes from our mandrill accounts page
MANDRILL_API_KEY = get_secret("mandrill_api_key")
# XXX: replace me
CAMO_URI = 'https://external-content.zulipcdn.net/'
@@ -42,7 +26,6 @@ CAMO_URI = 'https://external-content.zulipcdn.net/'
# Leave EMAIL_HOST unset or empty if you do not wish for emails to be sent
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'zulip@zulip.com'
EMAIL_HOST_PASSWORD = get_secret('email_password')
EMAIL_PORT = 587
EMAIL_USE_TLS = True

View File

@@ -32,6 +32,17 @@ STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'st
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
ENTERPRISE = DEPLOYED and config_file.get('machine', 'deploy_type') == 'enterprise'
secrets_file = ConfigParser.RawConfigParser()
if DEPLOYED:
secrets_file.read("/etc/zulip/zulip-secrets.conf")
else:
secrets_file.read("zproject/dev-secrets.conf")
def get_secret(key):
if secrets_file.has_option('secrets', key):
return secrets_file.get('secrets', key)
return None
# Import variables like secrets from the local_settings file
# Import local_settings after determining the deployment/machine type
from local_settings import *
@@ -435,6 +446,11 @@ GOOGLE_OAUTH2_CLIENT_SECRET = get_secret('google_oauth2_client_secret')
DROPBOX_APP_KEY = get_secret("dropbox_app_key")
MAILCHIMP_API_KEY = get_secret("mailchimp_api_key")
# This comes from our mandrill accounts page
MANDRILL_API_KEY = get_secret("mandrill_api_key")
# Twitter API credentials
# Secrecy not required because its only used for R/O requests.
# Please don't make us go over our rate limit.
@@ -473,6 +489,8 @@ if EMAIL_GATEWAY_BOT not in API_SUPER_USERS:
if EMAIL_GATEWAY_PATTERN != "":
EMAIL_GATEWAY_EXAMPLE = EMAIL_GATEWAY_PATTERN % ("support+abcdefg",)
DEPLOYMENT_ROLE_KEY = get_secret("deployment_role_key")
if DEPLOYED:
FEEDBACK_TARGET="https://zulip.com/api"
else:
@@ -917,6 +935,8 @@ elif not DEPLOYED:
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_PASSWORD = get_secret('email_password')
########################################################################
# MISC SETTINGS
########################################################################