@@ -9,29 +9,32 @@ class Settings(BaseSettings):
99
1010 database_url : str = "sqlite:///./dev.sqlite3"
1111
12- jwt_secret_key : str = "change-me-in-production"
12+ jwt_secret_key : str
1313 jwt_algorithm : str = "HS256"
1414 jwt_expire_minutes : int = 60
1515
1616 default_admin_email : str = "admin@company.com"
17- default_admin_password : str = "admin12345"
17+ default_admin_password : str
1818 default_admin_name : str = "System Admin"
1919 default_hr_email : str = "hr@company.com"
20- default_hr_password : str = "hr12345"
20+ default_hr_password : str
2121 default_hr_name : str = "HR Manager"
2222
2323 cors_origins : str = "http://127.0.0.1:5173,http://localhost:5173"
24- biometric_ingest_api_key : str = "local-biometric-key"
24+ biometric_ingest_api_key : str
2525
2626 @model_validator (mode = "after" )
2727 def validate_security_settings (self ) -> "Settings" :
28- if self .app_env .lower () == "production" :
29- if self .jwt_secret_key == "change-me-in-production" or len (self .jwt_secret_key ) < 32 :
30- raise ValueError ("JWT_SECRET_KEY must be set to a strong value in production" )
31- if self .default_admin_password == "admin12345" or self .default_hr_password == "hr12345" :
32- raise ValueError ("Default account passwords must be changed in production" )
33- if self .biometric_ingest_api_key == "local-biometric-key" or len (self .biometric_ingest_api_key ) < 16 :
34- raise ValueError ("BIOMETRIC_INGEST_API_KEY must be set to a strong value in production" )
28+ if len (self .jwt_secret_key ) < 32 :
29+ raise ValueError ("JWT_SECRET_KEY must be at least 32 characters" )
30+ if len (self .biometric_ingest_api_key ) < 16 :
31+ raise ValueError ("BIOMETRIC_INGEST_API_KEY must be at least 16 characters" )
32+ if self .default_admin_password in {"admin12345" , "change-me" }:
33+ raise ValueError ("DEFAULT_ADMIN_PASSWORD must not use weak default values" )
34+ if self .default_hr_password in {"hr12345" , "change-me" }:
35+ raise ValueError ("DEFAULT_HR_PASSWORD must not use weak default values" )
36+ if self .app_env .lower () == "production" and self .default_admin_password == self .default_hr_password :
37+ raise ValueError ("DEFAULT_ADMIN_PASSWORD and DEFAULT_HR_PASSWORD must be different in production" )
3538 return self
3639
3740 model_config = SettingsConfigDict (env_file = ".env" , env_file_encoding = "utf-8" , extra = "ignore" )
0 commit comments