feat!: the `general.secret_key` configuration field is now required (#2841)
BREAKING CHANGE: The `general.secret_key` configuration field is now required. Make sure to update your configuration file and add a secret key. Closes #2426
This commit is contained in:
parent
24ee3830c2
commit
0d2d1a2673
|
@ -1,5 +1,4 @@
|
|||
from os import getenv
|
||||
from warnings import warn
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from ._internal import (
|
||||
|
@ -25,15 +24,7 @@ LIBRETIME_CONFIG_FILEPATH = getenv("LIBRETIME_CONFIG_FILEPATH")
|
|||
|
||||
CONFIG = Config(LIBRETIME_CONFIG_FILEPATH) # type: ignore[arg-type, misc]
|
||||
|
||||
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
|
||||
SECRET_KEY = CONFIG.general.secret_key
|
||||
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@ general:
|
|||
# The internal API authentication key.
|
||||
# > this field is REQUIRED
|
||||
api_key:
|
||||
# The Django API secret key. If not defined, the value of [general.api_key] will be
|
||||
# used as fallback.
|
||||
# > this field will be REQUIRED starting with LibreTime 4.0.0
|
||||
# The Django API secret key.
|
||||
# > this field is REQUIRED
|
||||
secret_key:
|
||||
|
||||
# List of origins allowed to access resources on the server, the public url
|
||||
|
|
|
@ -7,9 +7,8 @@ general:
|
|||
# The internal API authentication key.
|
||||
# > this field is REQUIRED
|
||||
api_key:
|
||||
# The Django API secret key. If not defined, the value of [general.api_key] will be
|
||||
# used as fallback.
|
||||
# > this field will be REQUIRED starting with LibreTime 4.0.0
|
||||
# The Django API secret key.
|
||||
# > this field is REQUIRED
|
||||
secret_key:
|
||||
|
||||
# List of origins allowed to access resources on the server, the public url
|
||||
|
|
|
@ -7,9 +7,8 @@ general:
|
|||
# The internal API authentication key.
|
||||
# > this field is REQUIRED
|
||||
api_key: some_secret_api_key
|
||||
# The Django API secret key. If not defined, the value of [general.api_key] will be
|
||||
# used as fallback.
|
||||
# > this field will be REQUIRED starting with LibreTime 4.0.0
|
||||
# The Django API secret key.
|
||||
# > this field is REQUIRED
|
||||
secret_key:
|
||||
|
||||
# List of origins allowed to access resources on the server, the public url
|
||||
|
|
|
@ -42,8 +42,8 @@ general:
|
|||
# The internal API authentication key.
|
||||
# > this field is REQUIRED
|
||||
api_key: "some_random_generated_secret!"
|
||||
# The Django API secret key. If not defined, the value of [general.api_key] will be
|
||||
# used as fallback.
|
||||
# The Django API secret key.
|
||||
# > this field is REQUIRED
|
||||
secret_key: "some_random_generated_secret!"
|
||||
|
||||
# List of origins allowed to access resources on the server,
|
||||
|
|
|
@ -26,6 +26,10 @@ Please follow this **before the upgrade procedure**.
|
|||
|
||||
## :arrow_up: Upgrading
|
||||
|
||||
### The `general.secret_key` configuration field is required
|
||||
|
||||
The `general.secret_key` field in the [configuration file](../admin-manual/configuration.md#general) is now **required**, to prevent reusing the `general.api_key` for cryptographic usage.
|
||||
|
||||
## :warning: Known issues
|
||||
|
||||
The following issues may need a workaround for the time being. Please search the [issues](https://github.com/libretime/libretime/issues) before reporting problems not listed below.
|
||||
|
|
|
@ -7,9 +7,8 @@ general:
|
|||
# The internal API authentication key.
|
||||
# > this field is REQUIRED
|
||||
api_key:
|
||||
# The Django API secret key. If not defined, the value of [general.api_key] will be
|
||||
# used as fallback.
|
||||
# > this field will be REQUIRED starting with LibreTime 4.0.0
|
||||
# The Django API secret key.
|
||||
# > this field is REQUIRED
|
||||
secret_key:
|
||||
|
||||
# List of origins allowed to access resources on the server, the public url
|
||||
|
|
|
@ -35,7 +35,7 @@ class Schema implements ConfigurationInterface
|
|||
->arrayNode('general')->addDefaultsIfNotSet()->children()
|
||||
/**/->scalarNode('public_url')->cannotBeEmpty()->end()
|
||||
/**/->scalarNode('api_key')->cannotBeEmpty()->end()
|
||||
/**/->scalarNode('secret_key')->end()
|
||||
/**/->scalarNode('secret_key')->cannotBeEmpty()->end()
|
||||
/**/->arrayNode('allowed_cors_origins')->scalarPrototype()->defaultValue([])->end()->end()
|
||||
/**/->scalarNode('timezone')->cannotBeEmpty()->defaultValue("UTC")
|
||||
/* */->validate()->ifNotInArray(DateTimeZone::listIdentifiers())
|
||||
|
|
|
@ -10,6 +10,7 @@ def config():
|
|||
"general": {
|
||||
"public_url": "http://localhost:8080",
|
||||
"api_key": "some_api_key",
|
||||
"secret_key": "some_secret_key",
|
||||
},
|
||||
"stream": {
|
||||
"outputs": {
|
||||
|
|
|
@ -9,6 +9,7 @@ def make_config(**kwargs) -> Config:
|
|||
"general": {
|
||||
"public_url": "http://localhost:8080",
|
||||
"api_key": "some_api_key",
|
||||
"secret_key": "some_secret_key",
|
||||
},
|
||||
**kwargs,
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ else:
|
|||
class GeneralConfig(BaseModel):
|
||||
public_url: AnyHttpUrlStr
|
||||
api_key: str
|
||||
secret_key: Optional[str] = None
|
||||
secret_key: str
|
||||
|
||||
timezone: str = "UTC"
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ def test_general_config_timezone():
|
|||
defaults = {
|
||||
"public_url": "http://localhost:8080",
|
||||
"api_key": "api_key",
|
||||
"secret_key": "secret_key",
|
||||
}
|
||||
GeneralConfig(**defaults, timezone="UTC")
|
||||
GeneralConfig(**defaults, timezone="Europe/Berlin")
|
||||
|
|
Loading…
Reference in New Issue