feat: use secret_key config field instead of api_key (#2444)

Fixes #2426
This commit is contained in:
Jonas L 2023-03-22 10:14:11 +01:00 committed by GitHub
parent 74af2112a6
commit d800c5e280
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 1 deletions

View file

@ -1,4 +1,5 @@
from os import getenv
from warnings import warn
# pylint: disable=unused-import
from ._internal import (
@ -24,7 +25,15 @@ LIBRETIME_CONFIG_FILEPATH = getenv("LIBRETIME_CONFIG_FILEPATH")
CONFIG = Config(LIBRETIME_CONFIG_FILEPATH) # type: ignore[arg-type, misc]
SECRET_KEY = CONFIG.general.api_key
if CONFIG.general.secret_key is None:
warn(
"The [general.secret_key] configuration field is not set but will be required "
"in the next major release. Using [general.api_key] as fallback.",
FutureWarning,
)
SECRET_KEY = CONFIG.general.api_key
else:
SECRET_KEY = CONFIG.general.secret_key
ALLOWED_HOSTS = ["*"]

View file

@ -5,6 +5,7 @@ from .._fixtures import fixture_path
os.environ.setdefault("LIBRETIME_DEBUG", "true")
os.environ.setdefault("LIBRETIME_GENERAL_PUBLIC_URL", "http://localhost")
os.environ.setdefault("LIBRETIME_GENERAL_API_KEY", "testing")
os.environ.setdefault("LIBRETIME_GENERAL_SECRET_KEY", "testing")
os.environ.setdefault("LIBRETIME_STORAGE_PATH", str(fixture_path))
# pylint: disable=wrong-import-position,unused-import