Port cor-title and add file check endpoint
Fix some FA5 regressions Fix uploading cert files Add fix some icons
This commit is contained in:
parent
b5f630ba29
commit
561522c6d3
24 changed files with 159 additions and 56 deletions
|
@ -15,7 +15,7 @@ from data.database import configure
|
|||
from data.runmigration import run_alembic_migration
|
||||
from util.config.configutil import add_enterprise_config_defaults
|
||||
from util.config.database import sync_database_with_config
|
||||
from util.config.validator import validate_service_for_config, ValidatorContext
|
||||
from util.config.validator import validate_service_for_config, ValidatorContext, is_valid_config_upload_filename
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -302,3 +302,36 @@ class SuperUserConfigValidate(ApiResource):
|
|||
|
||||
|
||||
abort(403)
|
||||
|
||||
|
||||
@resource('/v1/superuser/config/file/<filename>')
|
||||
class SuperUserConfigFile(ApiResource):
|
||||
""" Resource for fetching the status of config files and overriding them. """
|
||||
@nickname('scConfigFileExists')
|
||||
def get(self, filename):
|
||||
""" Returns whether the configuration file with the given name exists. """
|
||||
if not is_valid_config_upload_filename(filename):
|
||||
abort(404)
|
||||
|
||||
return {
|
||||
'exists': config_provider.volume_file_exists(filename)
|
||||
}
|
||||
|
||||
|
||||
@nickname('scUpdateConfigFile')
|
||||
def post(self, filename):
|
||||
""" Updates the configuration file with the given name. """
|
||||
if not is_valid_config_upload_filename(filename):
|
||||
abort(404)
|
||||
|
||||
# Note: This method can be called before the configuration exists
|
||||
# to upload the database SSL cert.
|
||||
uploaded_file = request.files['file']
|
||||
if not uploaded_file:
|
||||
abort(400)
|
||||
|
||||
config_provider.save_volume_file(filename, uploaded_file)
|
||||
return {
|
||||
'status': True
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import logging
|
||||
import pathvalidate
|
||||
from flask import request, jsonify
|
||||
|
@ -6,7 +5,7 @@ from flask import request, jsonify
|
|||
from config_app.config_endpoints.exception import InvalidRequest
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname
|
||||
from config_app.config_util.ssl import load_certificate, CertInvalidException
|
||||
from config_app.c_app import app, config_provider
|
||||
from config_app.c_app import config_provider
|
||||
|
||||
from config_app.config_endpoints.api.superuser_models_pre_oci import pre_oci_model
|
||||
|
||||
|
@ -37,8 +36,8 @@ class SuperUserCustomCertificate(ApiResource):
|
|||
# Validate the certificate.
|
||||
try:
|
||||
logger.debug('Loading custom certificate %s', certpath)
|
||||
with config_provider.get_volume_file(cert_full_path) as f:
|
||||
load_certificate(f.read())
|
||||
cert = config_provider.get_volume_file(cert_full_path)
|
||||
load_certificate(cert)
|
||||
except CertInvalidException:
|
||||
logger.exception('Got certificate invalid error for cert %s', certpath)
|
||||
return '', 204
|
||||
|
@ -46,14 +45,6 @@ class SuperUserCustomCertificate(ApiResource):
|
|||
logger.exception('Got IO error for cert %s', certpath)
|
||||
return '', 204
|
||||
|
||||
# Call the update script to install the certificate immediately.
|
||||
if not app.config['TESTING']:
|
||||
logger.debug('Calling certs_install.sh')
|
||||
if os.system('/conf/init/certs_install.sh') != 0:
|
||||
raise Exception('Could not install certificates')
|
||||
|
||||
logger.debug('certs_install.sh completed')
|
||||
|
||||
return '', 204
|
||||
|
||||
@nickname('deleteCustomCertificate')
|
||||
|
@ -79,7 +70,7 @@ class SuperUserCustomCertificates(ApiResource):
|
|||
cert_views = []
|
||||
for extra_cert_path in extra_certs_found:
|
||||
try:
|
||||
cert = config_provider.get_volume_path(EXTRA_CA_DIRECTORY, extra_cert_path)
|
||||
cert = config_provider.get_volume_file(extra_cert_path)
|
||||
certificate = load_certificate(cert)
|
||||
cert_views.append({
|
||||
'path': extra_cert_path,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import logging
|
||||
import tarfile
|
||||
import cStringIO
|
||||
|
||||
|
@ -7,9 +6,7 @@ from flask import request, make_response
|
|||
from data.database import configure
|
||||
|
||||
from config_app.c_app import app, config_provider
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname, validate_json_request
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname
|
||||
|
||||
@resource('/v1/configapp/tarconfig')
|
||||
class TarConfigLoader(ApiResource):
|
||||
|
|
Reference in a new issue