core: pushing changes regarding MySQL ssl toggle that is now mandatory
This commit is contained in:
parent
65100920e3
commit
b7a006f7ee
@ -176,6 +176,12 @@ class DatabaseConfig:
|
|||||||
self.__config, "core", "database", "protocol", default="mysql"
|
self.__config, "core", "database", "protocol", default="mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ssl_enabled(self) -> str:
|
||||||
|
return CoreConfig.get_config_field(
|
||||||
|
self.__config, "core", "database", "ssl_enabled", default=False
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sha2_password(self) -> bool:
|
def sha2_password(self) -> bool:
|
||||||
return CoreConfig.get_config_field(
|
return CoreConfig.get_config_field(
|
||||||
|
@ -27,9 +27,9 @@ class Data:
|
|||||||
|
|
||||||
if self.config.database.sha2_password:
|
if self.config.database.sha2_password:
|
||||||
passwd = sha256(self.config.database.password.encode()).digest()
|
passwd = sha256(self.config.database.password.encode()).digest()
|
||||||
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{passwd.hex()}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}?charset=utf8mb4"
|
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{passwd.hex()}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}?charset=utf8mb4&ssl={str(self.config.database.ssl_enabled).lower()}"
|
||||||
else:
|
else:
|
||||||
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{self.config.database.password}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}?charset=utf8mb4"
|
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{self.config.database.password}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}?charset=utf8mb4&ssl={str(self.config.database.ssl_enabled).lower()}"
|
||||||
|
|
||||||
if Data.engine is None:
|
if Data.engine is None:
|
||||||
Data.engine = create_engine(self.__url, pool_recycle=3600)
|
Data.engine = create_engine(self.__url, pool_recycle=3600)
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
- `name`: Name of the database the server should expect. Default `aime`
|
- `name`: Name of the database the server should expect. Default `aime`
|
||||||
- `port`: Port the database server is listening on. Default `3306`
|
- `port`: Port the database server is listening on. Default `3306`
|
||||||
- `protocol`: Protocol used in the connection string, e.i `mysql` would result in `mysql://...`. Default `mysql`
|
- `protocol`: Protocol used in the connection string, e.i `mysql` would result in `mysql://...`. Default `mysql`
|
||||||
|
- `ssl_enabled`: Enforce SSL to be used in the connection string. Default `False`
|
||||||
- `sha2_password`: Whether or not the password in the connection string should be hashed via SHA2. Default `False`
|
- `sha2_password`: Whether or not the password in the connection string should be hashed via SHA2. Default `False`
|
||||||
- `loglevel`: Logging level for the database. Default `info`
|
- `loglevel`: Logging level for the database. Default `info`
|
||||||
- `memcached_host`: Host of the memcached server. Default `localhost`
|
- `memcached_host`: Host of the memcached server. Default `localhost`
|
||||||
|
@ -27,6 +27,7 @@ database:
|
|||||||
name: "aime"
|
name: "aime"
|
||||||
port: 3306
|
port: 3306
|
||||||
protocol: "mysql"
|
protocol: "mysql"
|
||||||
|
ssl_enabled: False
|
||||||
sha2_password: False
|
sha2_password: False
|
||||||
loglevel: "info"
|
loglevel: "info"
|
||||||
enable_memcached: True
|
enable_memcached: True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user