Changed SECRET_KEY to be randomly generated by manage.py when settings.py is first created, rather than to rely on people manually changing the default from settings_default when first starting the server.

This commit is contained in:
Griatch 2012-03-31 11:32:26 +02:00
parent 45c5be8468
commit 1ce5c6b84a
2 changed files with 81 additions and 59 deletions

View file

@ -29,6 +29,12 @@ if not os.path.exists('settings.py'):
# If settings.py doesn't already exist, create it and populate it with some # If settings.py doesn't already exist, create it and populate it with some
# basic stuff. # basic stuff.
# make random secret_key.
import random, string
secret_key = list((string.letters + string.digits + string.punctuation).replace("'",'"'))
random.shuffle(secret_key)
secret_key = "".join(secret_key[:40])
settings_file = open('settings.py', 'w') settings_file = open('settings.py', 'w')
_CREATED_SETTINGS = True _CREATED_SETTINGS = True
@ -46,54 +52,63 @@ if not os.path.exists('settings.py'):
from src.settings_default import * from src.settings_default import *
################################################### ######################################################################
# Evennia base server config # Evennia base server config
################################################### ######################################################################
################################################### ######################################################################
# Evennia Database config # Evennia Database config
################################################### ######################################################################
################################################### ######################################################################
# Evennia pluggable modules # Evennia pluggable modules
################################################### ######################################################################
################################################### ######################################################################
# Default command sets # Default command sets
################################################### ######################################################################
################################################### ######################################################################
# Typeclasses # Typeclasses
################################################### ######################################################################
################################################### ######################################################################
# Batch processors # Batch processors
################################################### ######################################################################
################################################### ######################################################################
# Game Time setup # Game Time setup
################################################### ######################################################################
################################################### ######################################################################
# In-game access # In-game access
################################################### ######################################################################
################################################### ######################################################################
# In-game Channels created from server start # In-game Channels created from server start
################################################### ######################################################################
################################################### ######################################################################
# External Channel connections # External Channel connections
################################################### ######################################################################
################################################### ######################################################################
# Config for Django web features # Config for Django web features
################################################### ######################################################################
################################################### ######################################################################
# Evennia components # Evennia components
################################################### ######################################################################
"""
######################################################################
# SECRET_KEY was randomly seeded when settings.py was first created.
# Don't share this with anybody. Warning: if you edit SECRET_KEY
# *after* creating any accounts, your users won't be able to login,
# since SECRET_KEY is used to salt passwords.
######################################################################
SECRET_KEY = '%s'
""" % secret_key
settings_file.write(string) settings_file.write(string)
settings_file.close() settings_file.close()

View file

@ -7,17 +7,17 @@ All settings changes should be done by copy-pasting the variable and
its value to game/settings.py. An empty game/settings.py can be its value to game/settings.py. An empty game/settings.py can be
auto-generated by running game/manage.py without any arguments. auto-generated by running game/manage.py without any arguments.
Hint: Don't copy&paste over more from this file than you actually want to Hint: Don't copy&paste over more from this file than you actually want
change. Anything you don't copy&paste will thus retain its default to change. Anything you don't copy&paste will thus retain its default
value - which may change as Evennia is developed. This way you can value - which may change as Evennia is developed. This way you can
always be sure of what you have changed and what is default behaviour. always be sure of what you have changed and what is default behaviour.
""" """
import os import os
################################################### ######################################################################
# Evennia base server config # Evennia base server config
################################################### ######################################################################
# This is the name of your game. Make it catchy! # This is the name of your game. Make it catchy!
SERVERNAME = "Evennia" SERVERNAME = "Evennia"
@ -58,10 +58,6 @@ SSL_INTERFACES = ['0.0.0.0']
# If false, only one session is allowed, all other are logged off # If false, only one session is allowed, all other are logged off
# when a new connects. # when a new connects.
ALLOW_MULTISESSION = True ALLOW_MULTISESSION = True
# Make this unique, and don't share it with anybody.
# NOTE: If you change this after creating any accounts, your users won't be
# able to login, as the SECRET_KEY is used to salt passwords.
SECRET_KEY = 'changeme!(*#&*($&*(#*(&SDFKJJKLS*(@#KJAS'
# The path that contains this settings.py file (no trailing slash). # The path that contains this settings.py file (no trailing slash).
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Path to the src directory containing the bulk of the codebase's code. # Path to the src directory containing the bulk of the codebase's code.
@ -108,9 +104,9 @@ ENCODINGS = ["utf-8", "latin-1", "ISO-8859-1"]
AMP_HOST = 'localhost' AMP_HOST = 'localhost'
AMP_PORT = 5000 AMP_PORT = 5000
################################################### ######################################################################
# Evennia Database config # Evennia Database config
################################################### ######################################################################
# Database config syntax for Django 1.2+. You can add several # Database config syntax for Django 1.2+. You can add several
# database engines in the dictionary (untested). # database engines in the dictionary (untested).
@ -141,9 +137,9 @@ DATABASE_PASSWORD = ''
DATABASE_HOST = '' DATABASE_HOST = ''
DATABASE_PORT = '' DATABASE_PORT = ''
################################################### ######################################################################
# Evennia pluggable modules # Evennia pluggable modules
################################################### ######################################################################
# An alternate command parser module to use # An alternate command parser module to use
COMMAND_PARSER = "src.commands.cmdparser.cmdparser" COMMAND_PARSER = "src.commands.cmdparser.cmdparser"
@ -166,14 +162,15 @@ AT_INITIAL_SETUP_HOOK_MODULE = ""
# Module holding at_server_start(), at_server_reload() and # Module holding at_server_start(), at_server_reload() and
# at_server_stop() methods. These methods will be called every time # at_server_stop() methods. These methods will be called every time
# the server starts, reloads and resets/stops. # the server starts, reloads and resets/stops.
AT_SERVER_STARTSTOP_MODULE = ""# Module holding server-side functions for out-of-band protocols to call. AT_SERVER_STARTSTOP_MODULE = ""
# Module holding server-side functions for out-of-band protocols to call.
OOB_FUNC_MODULE = "" OOB_FUNC_MODULE = ""
# Module holding MSSP meta data # Module holding MSSP meta data
MSSP_META_MODULE = "" MSSP_META_MODULE = ""
################################################### ######################################################################
# Default command sets # Default command sets
################################################### ######################################################################
# Note that with the exception of the unloggedin set (which is not # Note that with the exception of the unloggedin set (which is not
# stored anywhere), changing these paths will only affect NEW created # stored anywhere), changing these paths will only affect NEW created
# characters, not those already in play. So if you plan to change # characters, not those already in play. So if you plan to change
@ -188,9 +185,9 @@ CMDSET_DEFAULT = "src.commands.default.cmdset_default.DefaultCmdSet"
# Command set for players without a character (ooc) # Command set for players without a character (ooc)
CMDSET_OOC = "src.commands.default.cmdset_ooc.OOCCmdSet" CMDSET_OOC = "src.commands.default.cmdset_ooc.OOCCmdSet"
################################################### ######################################################################
# Typeclasses # Typeclasses
################################################### ######################################################################
# Base paths for typeclassed object classes. These paths must be # Base paths for typeclassed object classes. These paths must be
# defined relative evennia's root directory. They will be searched in # defined relative evennia's root directory. They will be searched in
@ -217,17 +214,17 @@ BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing"
# src/commands/default/unloggedin.py and customize. # src/commands/default/unloggedin.py and customize.
CHARACTER_DEFAULT_HOME = "2" CHARACTER_DEFAULT_HOME = "2"
################################################### ######################################################################
# Batch processors # Batch processors
################################################### ######################################################################
# Python path to a directory to be searched for batch scripts # Python path to a directory to be searched for batch scripts
# for the batch processors (.ev and/or .py files). # for the batch processors (.ev and/or .py files).
BASE_BATCHPROCESS_PATHS = ['game.gamesrc.world', 'contrib'] BASE_BATCHPROCESS_PATHS = ['game.gamesrc.world', 'contrib']
################################################### ######################################################################
# Game Time setup # Game Time setup
################################################### ######################################################################
# You don't actually have to use this, but it affects the routines in # You don't actually have to use this, but it affects the routines in
# src.utils.gametime.py and allows for a convenient measure to # src.utils.gametime.py and allows for a convenient measure to
@ -247,9 +244,9 @@ TIME_WEEK_PER_MONTH = 4
TIME_MONTH_PER_YEAR = 12 TIME_MONTH_PER_YEAR = 12
################################################### ######################################################################
# In-Game access # In-Game access
################################################### ######################################################################
# The access hiearchy, in climbing order. A higher permission in the # The access hiearchy, in climbing order. A higher permission in the
# hierarchy includes access of all levels below it. # hierarchy includes access of all levels below it.
@ -261,9 +258,9 @@ PERMISSION_PLAYER_DEFAULT = "Players"
LOCK_FUNC_MODULES = ("src.locks.lockfuncs",) LOCK_FUNC_MODULES = ("src.locks.lockfuncs",)
################################################### ######################################################################
# In-game Channels created from server start # In-game Channels created from server start
################################################### ######################################################################
# Defines a dict with one key for each from-start # Defines a dict with one key for each from-start
# channel. Each key points to a tuple containing # channel. Each key points to a tuple containing
@ -280,9 +277,9 @@ CHANNEL_MUDINFO = ("MUDinfo", '', 'Informative messages',
CHANNEL_CONNECTINFO = ("MUDconnections", '', 'Connection log', CHANNEL_CONNECTINFO = ("MUDconnections", '', 'Connection log',
"control:perm(Immortals);listen:perm(Wizards);send:false()") "control:perm(Immortals);listen:perm(Wizards);send:false()")
################################################### ######################################################################
# External Channel connections # External Channel connections
################################################### ######################################################################
# Note: You do *not* have to make your MUD open to # Note: You do *not* have to make your MUD open to
# the public to use the external connections, they # the public to use the external connections, they
@ -321,9 +318,9 @@ IMC2_SERVER_PWD = ""
RSS_ENABLED=False RSS_ENABLED=False
RSS_UPDATE_INTERVAL = 60*10 # 10 minutes RSS_UPDATE_INTERVAL = 60*10 # 10 minutes
################################################### ######################################################################
# Config for Django web features # Config for Django web features
################################################### ######################################################################
# While DEBUG is False, show a regular server error page on the web # While DEBUG is False, show a regular server error page on the web
# stuff, email the traceback to the people in the ADMINS tuple # stuff, email the traceback to the people in the ADMINS tuple
@ -417,9 +414,9 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.debug', 'django.core.context_processors.debug',
'src.web.utils.general_context.general_context',) 'src.web.utils.general_context.general_context',)
################################################### ######################################################################
# Evennia components # Evennia components
################################################### ######################################################################
# Global and Evennia-specific apps. This ties everything together so we can # Global and Evennia-specific apps. This ties everything together so we can
# refer to app models and perform DB syncs. # refer to app models and perform DB syncs.
@ -445,9 +442,9 @@ AUTH_PROFILE_MODULE = "players.PlayerDB"
# Use a custom test runner that just tests Evennia-specific apps. # Use a custom test runner that just tests Evennia-specific apps.
TEST_RUNNER = 'src.utils.test_utils.EvenniaTestSuiteRunner' TEST_RUNNER = 'src.utils.test_utils.EvenniaTestSuiteRunner'
################################################### ######################################################################
# Django extensions # Django extensions
################################################### ######################################################################
# Django extesions are useful third-party tools that are not # Django extesions are useful third-party tools that are not
# always included in the default django distro. # always included in the default django distro.
@ -456,9 +453,19 @@ try:
INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',) INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',)
except ImportError: except ImportError:
pass pass
# South handles automatic database scheme migrations when evennia updates # South handles automatic database scheme migrations when evennia
# updates
try: try:
import south import south
INSTALLED_APPS = INSTALLED_APPS + ('south',) INSTALLED_APPS = INSTALLED_APPS + ('south',)
except ImportError: except ImportError:
pass pass
#######################################################################
# SECRET_KEY
#######################################################################
# This is the salt for account passwords. It is a fallback for the
# SECRET_KEY setting in settings.py, which is randomly seeded when
# settings.py is first created. If copying from here, make sure to
# change it!
SECRET_KEY = 'changeme!(*#&*($&*(#*(&SDFKJJKLS*(@#KJAS'