[#4] Make password and api_key optional in AgencyConf
This commit is contained in:
parent
abf5b071a4
commit
acd06b522a
|
|
@ -1,3 +1,4 @@
|
|||
from typing import Optional
|
||||
from pydantic import ConfigDict, BaseModel, Field
|
||||
|
||||
|
||||
|
|
@ -9,13 +10,13 @@ class AgencyConf(BaseModel):
|
|||
pattern='^[a-zA-Z0-9]+$',
|
||||
examples=["mfdz"])
|
||||
|
||||
api_key: str = Field(
|
||||
api_key: Optional[str] = Field(None,
|
||||
description="The agency's API key for using the API",
|
||||
min_length=20,
|
||||
max_length=256,
|
||||
pattern=r'^[a-zA-Z0-9]+$',
|
||||
examples=["d8yLuY4DqMEUCLcfJASi"])
|
||||
password: str = Field(
|
||||
password: Optional[str] = Field(None,
|
||||
description="The agency's password for generating JWT tokens",
|
||||
min_length=8,
|
||||
max_length=256,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class AgencyConfService:
|
|||
api_key = agency_conf.api_key
|
||||
|
||||
self.agency_id_to_agency_conf[agency_id] = agency_conf
|
||||
if api_key is not None:
|
||||
self.api_key_to_agency_id[api_key] = agency_conf.agency_id
|
||||
|
||||
def get_agency_conf(self, agency_id: str) -> AgencyConf:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from pydantic_settings import BaseSettings
|
|||
|
||||
class Config(BaseSettings):
|
||||
admin_token: str
|
||||
secret_key: str
|
||||
ride2go_query_data: str
|
||||
env: str = 'DEV'
|
||||
graphhopper_base_url: str = 'https://api.mfdz.de/gh'
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ from amarillo.services.agencies import AgencyService
|
|||
from amarillo.services.agencyconf import AgencyConfService
|
||||
from amarillo.models.Carpool import Agency
|
||||
|
||||
from amarillo.services.config import config
|
||||
from amarillo.services.secrets import secrets
|
||||
|
||||
SECRET_KEY = config.secret_key
|
||||
SECRET_KEY = secrets.secret_key
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from pydantic_settings import BaseSettings
|
|||
class Secrets(BaseSettings):
|
||||
model_config = ConfigDict(extra='allow')
|
||||
ride2go_token: str = Field(None, env = 'RIDE2GO_TOKEN')
|
||||
secret_key: str
|
||||
|
||||
|
||||
# Read if file exists, otherwise no error (it's in .gitignore)
|
||||
|
|
|
|||
Loading…
Reference in a new issue