From 976c800c4ba5bd1f4856ea2fa112e89af979bacf Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 4 Dec 2023 15:38:11 +0000 Subject: https: T5772: require that at least one valid API key is present --- src/conf_mode/http-api.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/conf_mode/http-api.py b/src/conf_mode/http-api.py index 2ade3476d..dc75e79b7 100755 --- a/src/conf_mode/http-api.py +++ b/src/conf_mode/http-api.py @@ -94,15 +94,18 @@ def get_config(config=None): key = conf.return_value('keys id {0} key'.format(name)) new_key = { 'id': name, 'key': key } http_api['api_keys'].append(new_key) - keys_added = True - - if keys_added and default_key: - if default_key in http_api['api_keys']: - http_api['api_keys'].remove(default_key) + else: + raise ConfigError(f'Missing HTTPS API key string for key id "{name}"') return http_api def verify(http_api): + # Verify API server settings, if present + keys = http_api['api_keys'] + + if not keys: + raise ConfigError('At least one HTTPS API key is required') + return None def generate(http_api): -- cgit v1.2.3