2015-01-04 19:38:41 +00:00
|
|
|
from random import SystemRandom
|
2016-09-26 09:13:59 +00:00
|
|
|
from uuid import uuid4
|
2015-01-04 19:38:41 +00:00
|
|
|
|
|
|
|
def generate_secret_key():
|
|
|
|
cryptogen = SystemRandom()
|
|
|
|
return str(cryptogen.getrandbits(256))
|
|
|
|
|
|
|
|
|
2015-01-05 18:01:32 +00:00
|
|
|
def add_enterprise_config_defaults(config_obj, current_secret_key, hostname):
|
2015-01-04 19:38:41 +00:00
|
|
|
""" Adds/Sets the config defaults for enterprise registry config. """
|
|
|
|
# These have to be false.
|
|
|
|
config_obj['TESTING'] = False
|
|
|
|
config_obj['USE_CDN'] = False
|
|
|
|
|
|
|
|
# Default features that are on.
|
|
|
|
config_obj['FEATURE_USER_LOG_ACCESS'] = config_obj.get('FEATURE_USER_LOG_ACCESS', True)
|
|
|
|
config_obj['FEATURE_USER_CREATION'] = config_obj.get('FEATURE_USER_CREATION', True)
|
2015-05-19 21:52:44 +00:00
|
|
|
config_obj['FEATURE_ANONYMOUS_ACCESS'] = config_obj.get('FEATURE_ANONYMOUS_ACCESS', True)
|
2016-09-20 20:45:00 +00:00
|
|
|
config_obj['FEATURE_REQUIRE_TEAM_INVITE'] = config_obj.get('FEATURE_REQUIRE_TEAM_INVITE', True)
|
2017-04-05 18:01:55 +00:00
|
|
|
config_obj['FEATURE_CHANGE_TAG_EXPIRATION'] = config_obj.get('FEATURE_CHANGE_TAG_EXPIRATION',
|
|
|
|
True)
|
2017-05-24 16:57:55 +00:00
|
|
|
config_obj['FEATURE_DIRECT_LOGIN'] = config_obj.get('FEATURE_DIRECT_LOGIN', True)
|
2015-01-04 19:38:41 +00:00
|
|
|
|
|
|
|
# Default features that are off.
|
|
|
|
config_obj['FEATURE_MAILING'] = config_obj.get('FEATURE_MAILING', False)
|
|
|
|
config_obj['FEATURE_BUILD_SUPPORT'] = config_obj.get('FEATURE_BUILD_SUPPORT', False)
|
2016-03-08 23:08:40 +00:00
|
|
|
config_obj['FEATURE_ACI_CONVERSION'] = config_obj.get('FEATURE_ACI_CONVERSION', False)
|
2017-06-16 19:10:15 +00:00
|
|
|
config_obj['FEATURE_APP_REGISTRY'] = config_obj.get('FEATURE_APP_REGISTRY', False)
|
2016-02-16 20:31:23 +00:00
|
|
|
|
|
|
|
# Default the signer config.
|
|
|
|
config_obj['GPG2_PRIVATE_KEY_FILENAME'] = config_obj.get('GPG2_PRIVATE_KEY_FILENAME',
|
|
|
|
'signing-private.gpg')
|
|
|
|
config_obj['GPG2_PUBLIC_KEY_FILENAME'] = config_obj.get('GPG2_PUBLIC_KEY_FILENAME',
|
|
|
|
'signing-public.gpg')
|
|
|
|
config_obj['SIGNING_ENGINE'] = config_obj.get('SIGNING_ENGINE', 'gpg2')
|
2015-01-04 19:38:41 +00:00
|
|
|
|
2016-05-02 19:29:31 +00:00
|
|
|
# Default security scanner config.
|
|
|
|
config_obj['FEATURE_SECURITY_NOTIFICATIONS'] = config_obj.get(
|
|
|
|
'FEATURE_SECURITY_NOTIFICATIONS', True)
|
|
|
|
|
|
|
|
config_obj['FEATURE_SECURITY_SCANNER'] = config_obj.get(
|
|
|
|
'FEATURE_SECURITY_SCANNER', False)
|
|
|
|
|
|
|
|
config_obj['SECURITY_SCANNER_ISSUER_NAME'] = config_obj.get(
|
|
|
|
'SECURITY_SCANNER_ISSUER_NAME', 'security_scanner')
|
|
|
|
|
2017-04-05 18:01:55 +00:00
|
|
|
# Default time machine config.
|
|
|
|
config_obj['TAG_EXPIRATION_OPTIONS'] = config_obj.get('TAG_EXPIRATION_OPTIONS',
|
|
|
|
['0s', '1d', '1w', '2w', '4w'])
|
|
|
|
config_obj['DEFAULT_TAG_EXPIRATION'] = config_obj.get('DEFAULT_TAG_EXPIRATION', '2w')
|
|
|
|
|
2016-03-08 23:08:40 +00:00
|
|
|
# Default mail setings.
|
2016-05-02 19:29:31 +00:00
|
|
|
config_obj['MAIL_USE_TLS'] = config_obj.get('MAIL_USE_TLS', True)
|
|
|
|
config_obj['MAIL_PORT'] = config_obj.get('MAIL_PORT', 587)
|
|
|
|
config_obj['MAIL_DEFAULT_SENDER'] = config_obj.get('MAIL_DEFAULT_SENDER', 'support@quay.io')
|
2016-03-08 23:08:40 +00:00
|
|
|
|
2015-01-05 18:01:32 +00:00
|
|
|
# Default auth type.
|
|
|
|
if not 'AUTHENTICATION_TYPE' in config_obj:
|
|
|
|
config_obj['AUTHENTICATION_TYPE'] = 'Database'
|
|
|
|
|
2015-01-04 19:38:41 +00:00
|
|
|
# Default secret key.
|
|
|
|
if not 'SECRET_KEY' in config_obj:
|
2015-01-05 17:31:02 +00:00
|
|
|
config_obj['SECRET_KEY'] = current_secret_key
|
2015-01-04 19:38:41 +00:00
|
|
|
|
2016-09-26 09:13:59 +00:00
|
|
|
# Default torrent pepper.
|
|
|
|
if not 'BITTORRENT_FILENAME_PEPPER' in config_obj:
|
|
|
|
config_obj['BITTORRENT_FILENAME_PEPPER'] = str(uuid4())
|
|
|
|
|
2015-01-04 19:38:41 +00:00
|
|
|
# Default storage configuration.
|
|
|
|
if not 'DISTRIBUTED_STORAGE_CONFIG' in config_obj:
|
2015-10-26 23:06:05 +00:00
|
|
|
config_obj['DISTRIBUTED_STORAGE_PREFERENCE'] = ['default']
|
2015-01-04 19:38:41 +00:00
|
|
|
config_obj['DISTRIBUTED_STORAGE_CONFIG'] = {
|
2015-10-26 23:06:05 +00:00
|
|
|
'default': ['LocalStorage', {'storage_path': '/datastorage/registry'}]
|
2015-01-04 19:38:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-26 23:06:05 +00:00
|
|
|
config_obj['USERFILES_LOCATION'] = 'default'
|
2015-01-04 19:38:41 +00:00
|
|
|
config_obj['USERFILES_PATH'] = 'userfiles/'
|
|
|
|
|
2015-10-26 23:06:05 +00:00
|
|
|
config_obj['LOG_ARCHIVE_LOCATION'] = 'default'
|
2015-06-11 17:43:29 +00:00
|
|
|
|
2015-01-05 18:01:32 +00:00
|
|
|
if not 'SERVER_HOSTNAME' in config_obj:
|
|
|
|
config_obj['SERVER_HOSTNAME'] = hostname
|
|
|
|
|
2015-01-04 19:38:41 +00:00
|
|
|
# Misc configuration.
|
|
|
|
config_obj['PREFERRED_URL_SCHEME'] = config_obj.get('PREFERRED_URL_SCHEME', 'http')
|
2016-05-02 19:29:31 +00:00
|
|
|
config_obj['ENTERPRISE_LOGO_URL'] = config_obj.get(
|
2016-05-04 19:20:27 +00:00
|
|
|
'ENTERPRISE_LOGO_URL', '/static/img/quay-logo.png')
|
2017-02-24 18:20:29 +00:00
|
|
|
config_obj['TEAM_RESYNC_STALE_TIME'] = '60m'
|