feat: Major updates to backend structure and security enhancements
- Removed `COMMON_ERRORS.md` file to streamline documentation. - Added `Flask-Limiter` for rate limiting and `redis` for session management in `requirements.txt`. - Expanded `ROADMAP.md` to include completed security features and planned enhancements for version 2.2. - Enhanced `setup_myp.sh` for ultra-secure kiosk installation, including system hardening and security configurations. - Updated `app.py` to integrate CSRF protection and improved logging setup. - Refactored user model to include username and active status for better user management. - Improved job scheduler with uptime tracking and task management features. - Updated various templates for a more cohesive user interface and experience.
This commit is contained in:
74
backend/app/config/__init__.py
Normal file
74
backend/app/config/__init__.py
Normal file
@@ -0,0 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Configuration Package for MYP Platform
|
||||
======================================
|
||||
|
||||
This package contains all configuration modules for the Mercedes-Benz 3D Printing Platform.
|
||||
|
||||
Modules:
|
||||
- security: Security configuration and middleware
|
||||
- database: Database configuration and settings
|
||||
- logging: Logging configuration
|
||||
- app_config: Main application configuration
|
||||
"""
|
||||
|
||||
__version__ = "2.0.0"
|
||||
__author__ = "MYP Development Team"
|
||||
|
||||
# Import main configuration modules
|
||||
try:
|
||||
from .security import SecurityConfig, get_security_headers
|
||||
from .app_config import Config, DevelopmentConfig, ProductionConfig, TestingConfig
|
||||
except ImportError as e:
|
||||
print(f"Warning: Could not import configuration modules: {e}")
|
||||
# Fallback configurations
|
||||
SecurityConfig = None
|
||||
get_security_headers = None
|
||||
Config = None
|
||||
|
||||
# Export main configuration classes
|
||||
__all__ = [
|
||||
'SecurityConfig',
|
||||
'get_security_headers',
|
||||
'Config',
|
||||
'DevelopmentConfig',
|
||||
'ProductionConfig',
|
||||
'TestingConfig'
|
||||
]
|
||||
|
||||
def get_config(config_name='development'):
|
||||
"""
|
||||
Get configuration object based on environment name.
|
||||
|
||||
Args:
|
||||
config_name (str): Configuration environment name
|
||||
|
||||
Returns:
|
||||
Config: Configuration object
|
||||
"""
|
||||
configs = {
|
||||
'development': DevelopmentConfig,
|
||||
'production': ProductionConfig,
|
||||
'testing': TestingConfig
|
||||
}
|
||||
|
||||
return configs.get(config_name, DevelopmentConfig)
|
||||
|
||||
def validate_config(config_obj):
|
||||
"""
|
||||
Validate configuration object.
|
||||
|
||||
Args:
|
||||
config_obj: Configuration object to validate
|
||||
|
||||
Returns:
|
||||
bool: True if valid, False otherwise
|
||||
"""
|
||||
required_attrs = ['SECRET_KEY', 'DATABASE_URL']
|
||||
|
||||
for attr in required_attrs:
|
||||
if not hasattr(config_obj, attr):
|
||||
print(f"Missing required configuration: {attr}")
|
||||
return False
|
||||
|
||||
return True
|
Reference in New Issue
Block a user