Get end-to-end configuration setup working, including verification (except for Github, which is in progress)
This commit is contained in:
parent
825455ea6c
commit
63504c87fb
14 changed files with 611 additions and 206 deletions
|
@ -9,18 +9,17 @@ from endpoints.api import (ApiResource, nickname, resource, internal_only, show_
|
|||
from endpoints.common import common_login
|
||||
from app import app, OVERRIDE_CONFIG_YAML_FILENAME, OVERRIDE_CONFIG_DIRECTORY
|
||||
from data import model
|
||||
from data.database import User, validate_database_url
|
||||
from auth.permissions import SuperUserPermission
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from util.configutil import (import_yaml, export_yaml, add_enterprise_config_defaults,
|
||||
set_config_value)
|
||||
from data.database import User
|
||||
from util.config.configutil import (import_yaml, export_yaml, add_enterprise_config_defaults,
|
||||
set_config_value)
|
||||
from util.config.validator import validate_service_for_config, SSL_FILENAMES
|
||||
|
||||
import features
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_FILE_WHITELIST = ['ssl.key', 'ssl.cert']
|
||||
|
||||
def database_is_valid():
|
||||
try:
|
||||
User.select().limit(1)
|
||||
|
@ -131,7 +130,7 @@ class SuperUserConfigFile(ApiResource):
|
|||
@nickname('scConfigFileExists')
|
||||
def get(self, filename):
|
||||
""" Returns whether the configuration file with the given name exists. """
|
||||
if not filename in CONFIG_FILE_WHITELIST:
|
||||
if not filename in SSL_FILENAMES:
|
||||
abort(404)
|
||||
|
||||
if SuperUserPermission().can():
|
||||
|
@ -260,19 +259,6 @@ class SuperUserConfigValidate(ApiResource):
|
|||
# this is also safe since this method does not access any information not given in the request.
|
||||
if not os.path.exists(OVERRIDE_CONFIG_YAML_FILENAME) or SuperUserPermission().can():
|
||||
config = request.get_json()['config']
|
||||
if service == 'database':
|
||||
try:
|
||||
validate_database_url(config['DB_URI'])
|
||||
return {
|
||||
'status': True
|
||||
}
|
||||
except Exception as ex:
|
||||
logger.exception('Could not validate database')
|
||||
return {
|
||||
'status': False,
|
||||
'reason': str(ex)
|
||||
}
|
||||
|
||||
return {}
|
||||
return validate_service_for_config(service, config)
|
||||
|
||||
abort(403)
|
Reference in a new issue