'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', #'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make a dictionary of default keys default_keys = { 'SECRET_KEY': 'vm4rl5*ymb@2&d_(gc$gb-^twq9w(u69hi--%$5xrh!xk(t%hw', } # Replace default keys with dynamic values if we are in OpenShift use_keys = default_keys if ON_OPENSHIFT: imp.find_module('openshiftlibs') import openshiftlibs use_keys = openshiftlibs.openshift_secure(default_keys) # Make this unique, and don't share it with anybody. SECRET_KEY = use_keys['SECRET_KEY'] # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', #'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
# various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', #'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make a dictionary of default keys default_keys = { 'SECRET_KEY': 'vm4rl5*ymb@2&d_(gc$gb-^twq9w(u69hi--%$5xrh!xk(t%hw' } # Replace default keys with dynamic values if we are in OpenShift use_keys = default_keys if ON_OPENSHIFT: imp.find_module('openshiftlibs') import openshiftlibs use_keys = openshiftlibs.openshift_secure(default_keys) # Make this unique, and don't share it with anybody. SECRET_KEY = use_keys['SECRET_KEY'] # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', #'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
# Grab the default security info c.execute('SELECT password FROM AUTH_USER WHERE id = 1') pw_info = c.fetchone()[0] # The password is stored as [hashtype]$[salt]$[hashed] pw_fields = pw_info.split("$") hashtype = pw_fields[0] old_salt = pw_fields[1] old_pass = pw_fields[2] # Randomly generate a new password and a new salt # The PASSWORD value below just sets the length (12) # for the real new password. old_keys = { 'SALT': old_salt, 'PASS': '******' } use_keys = openshiftlibs.openshift_secure(old_keys) # Encrypt the new password new_salt = use_keys['SALT'] new_pass = use_keys['PASS'] new_hashed = hashlib.sha1(new_salt + new_pass).hexdigest() new_pw_info = "$".join([hashtype,new_salt,new_hashed]) # Update the database c.execute('UPDATE AUTH_USER SET password = ? WHERE id = 1', [new_pw_info]) conn.commit() c.close() conn.close() # Print the new password info print "CLIENT_MESSAGE: The password for user 'admin' in your Django app is " + new_pass + " ...be sure to write this down as you will not see this message again.\n"
} DATABASES['default'] = DATABASES['sqlite'] APPENLIGHT = e_client.get_config() if os.getenv('APPENLIGHT_KEY') else {} MIDDLEWARE_CLASSES = ('appenlight_client.django_middleware.AppenlightMiddleware', ) + MIDDLEWARE_CLASSES if os.getenv('OPENSHIFT_POSTGRESQL_DB_USERNAME'): DATABASES['postgres'] = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': os.environ['OPENSHIFT_APP_NAME'], 'USER': os.environ['OPENSHIFT_POSTGRESQL_DB_USERNAME'], 'PASSWORD': os.environ['OPENSHIFT_POSTGRESQL_DB_PASSWORD'], 'HOST': os.environ['OPENSHIFT_POSTGRESQL_DB_HOST'], 'PORT': os.environ['OPENSHIFT_POSTGRESQL_DB_PORT'], } DATABASES['default'] = DATABASES['postgres'] if os.getenv('CLOUDSQL_KEY'): DATABASES['cloudsql'] = get_cloud_db_settings(os.environ['CLOUDSQL_KEY']) if DATABASES['cloudsql']: DATABASES['default'] = DATABASES['cloudsql'] if os.getenv('CLOUDCACHE_KEY'): CACHES = { 'default': get_cloud_cache_settings(os.environ['CLOUDCACHE_KEY']) } SECRET_KEY = openshift_secure('qi!k%l+n@hs8l8%)t@j2bl6_jj_x2q-g^em=i!6m17(7x1^$9r')
#PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) # os.environ['OPENSHIFT_MYSQL_DB_*'] variables can be used with databases created # with rhc app cartridge add (see /README in this git repo) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'local', 'USER': '******', 'PASSWORD': '******', 'HOST': os.environ['OPENSHIFT_POSTGRESQL_DB_HOST'], 'PORT': os.environ['OPENSHIFT_POSTGRESQL_DB_PORT'], } } MEDIA_ROOT = os.environ.get('OPENSHIFT_DATA_DIR', '') MEDIA_URL = '' STATIC_ROOT = os.path.join(PROJECT_ROOT, '..', 'static') STATIC_URL = '/static/' #ADMIN_MEDIA_PREFIX = '/static/admin/' # Replace default keys with dynamic values if we are in OpenShift USE_KEYS = openshiftlibs.openshift_secure({ 'SECRET_KEY': 'vm4rl5*ymb@2&d_(gc$gb-^twq9w(u69hi--%$5xrh!xk(t%hw', }) # Make this unique, and don't share it with anybody. SECRET_KEY = USE_KEYS['SECRET_KEY']