Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from datetime import timedelta

import hashlib
import os
import os.path
import socket
Expand Down Expand Up @@ -935,10 +934,7 @@ def create_partitioned_queues(name):

# See sentry/options/__init__.py for more information
SENTRY_OPTIONS = {}
SENTRY_DEFAULT_OPTIONS = {
# Make this unique, and don't share it with anybody.
'system.secret-key': hashlib.md5(socket.gethostname() + ')*)&8a36)6%74e@-ne5(-!8a(vv#tkv)(eyg&@0=zd^pl!7=y@').hexdigest(),
}
SENTRY_DEFAULT_OPTIONS = {}

# You should not change this setting after your database has been created
# unless you have altered all schemas first
Expand Down
8 changes: 8 additions & 0 deletions src/sentry/runner/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ def apply_legacy_settings(settings):
settings.DEFAULT_FROM_EMAIL = settings.SENTRY_OPTIONS.get(
'mail.from', settings.SENTRY_DEFAULT_OPTIONS.get('mail.from'))

# HACK(mattrobenolt): This is a one-off assertion for a system.secret-key value.
# If this becomes a pattern, we could add another flag to the OptionsManager to cover this, but for now
# this is the only value that should prevent the app from booting up. Currently FLAG_REQUIRED is used to
# trigger the Installation Wizard, not abort startup.
if not settings.SENTRY_OPTIONS.get('system.secret-key'):
from .importer import ConfigurationError
raise ConfigurationError("`system.secret-key` MUST be set. Use 'sentry config generate-secret-key' to get one.")


def skip_migration_if_applied(settings, app_name, table_name,
name='0001_initial'):
Expand Down
9 changes: 9 additions & 0 deletions tests/sentry/runner/test_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_apply_legacy_settings(settings):
settings.SENTRY_SMTP_HOSTNAME = 'reply-hostname'
settings.MAILGUN_API_KEY = 'mailgun-api-key'
settings.SENTRY_OPTIONS = {
'system.secret-key': 'secret-key',
'mail.from': 'mail-from',
}
apply_legacy_settings(settings)
Expand All @@ -179,6 +180,7 @@ def test_apply_legacy_settings(settings):
'system.admin-email': 'admin-email',
'system.url-prefix': 'http://url-prefix',
'system.rate-limit': 10,
'system.secret-key': 'secret-key',
'redis.clusters': {'default': {'foo': 'bar'}},
'mail.from': 'mail-from',
'mail.enable-replies': True,
Expand All @@ -191,5 +193,12 @@ def test_apply_legacy_settings(settings):

def test_initialize_app(settings):
"Just a sanity check of the full initialization process"
settings.SENTRY_OPTIONS = {'system.secret-key': 'secret-key'}
bootstrap_options(settings)
apply_legacy_settings(settings)


def test_require_secret_key(settings):
assert 'system.secret-key' not in settings.SENTRY_OPTIONS
with pytest.raises(ConfigurationError):
apply_legacy_settings(settings)