Enhance database URI security and add URL encoding (#6668)
This commit is contained in:
parent
ebcc07e3e9
commit
0b4c26578e
1 changed files with 2 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from pydantic import Field, NonNegativeInt, PositiveInt, computed_field
|
from pydantic import Field, NonNegativeInt, PositiveInt, computed_field
|
||||||
from pydantic_settings import BaseSettings
|
from pydantic_settings import BaseSettings
|
||||||
|
|
@ -104,7 +105,7 @@ class DatabaseConfig:
|
||||||
).strip("&")
|
).strip("&")
|
||||||
db_extras = f"?{db_extras}" if db_extras else ""
|
db_extras = f"?{db_extras}" if db_extras else ""
|
||||||
return (f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://"
|
return (f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://"
|
||||||
f"{self.DB_USERNAME}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}"
|
f"{quote_plus(self.DB_USERNAME)}:{quote_plus(self.DB_PASSWORD)}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}"
|
||||||
f"{db_extras}")
|
f"{db_extras}")
|
||||||
|
|
||||||
SQLALCHEMY_POOL_SIZE: NonNegativeInt = Field(
|
SQLALCHEMY_POOL_SIZE: NonNegativeInt = Field(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue