- Add HTTPSConfig model for managing HTTPS settings - Add admin routes for HTTPS configuration management - Add beautiful admin template for HTTPS configuration - Add database migration for https_config table - Add CLI utility for HTTPS management - Add setup script for automated configuration - Add Caddy configuration generator and manager - Add comprehensive documentation (3 guides) - Add HTTPS Configuration card to admin dashboard - Implement input validation and security features - Add admin-only access control with audit trail - Add real-time configuration preview - Integrate with existing Caddy reverse proxy Features: - Enable/disable HTTPS from web interface - Configure domain, hostname, IP address, port - Automatic SSL certificate management via Let's Encrypt - Real-time Caddyfile generation and reload - Full audit trail with admin username and timestamps - Support for HTTPS and HTTP fallback access points - Beautiful, mobile-responsive UI Modified files: - app/models/__init__.py (added HTTPSConfig import) - app/blueprints/admin.py (added HTTPS routes) - app/templates/admin/admin.html (added HTTPS card) - docker-compose.yml (added Caddyfile mount and admin port) New files: - app/models/https_config.py - app/blueprints/https_config.html - app/utils/caddy_manager.py - https_manager.py - setup_https.sh - migrations/add_https_config_table.py - migrations/add_email_to_https_config.py - HTTPS_STATUS.txt - Documentation files (3 markdown guides)
73 lines
2.0 KiB
Python
Executable File
73 lines
2.0 KiB
Python
Executable File
"""Server log model for audit trail."""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from app.extensions import db
|
|
|
|
|
|
class ServerLog(db.Model):
|
|
"""Server log model for tracking system events.
|
|
|
|
Attributes:
|
|
id: Primary key
|
|
level: Log level (info, warning, error)
|
|
message: Log message content
|
|
timestamp: Event timestamp
|
|
"""
|
|
__tablename__ = 'server_log'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
level = db.Column(db.String(20), nullable=False, index=True, default='info')
|
|
message = db.Column(db.Text, nullable=False)
|
|
timestamp = db.Column(db.DateTime, default=datetime.utcnow,
|
|
nullable=False, index=True)
|
|
|
|
def __repr__(self) -> str:
|
|
"""String representation of ServerLog."""
|
|
return f'<ServerLog [{self.level.upper()}] {self.message[:50]}>'
|
|
|
|
@classmethod
|
|
def log_info(cls, message: str) -> 'ServerLog':
|
|
"""Create an info level log entry.
|
|
|
|
Args:
|
|
message: Log message
|
|
|
|
Returns:
|
|
ServerLog instance
|
|
"""
|
|
log = cls(level='info', message=message)
|
|
db.session.add(log)
|
|
db.session.commit()
|
|
return log
|
|
|
|
@classmethod
|
|
def log_warning(cls, message: str) -> 'ServerLog':
|
|
"""Create a warning level log entry.
|
|
|
|
Args:
|
|
message: Log message
|
|
|
|
Returns:
|
|
ServerLog instance
|
|
"""
|
|
log = cls(level='warning', message=message)
|
|
db.session.add(log)
|
|
db.session.commit()
|
|
return log
|
|
|
|
@classmethod
|
|
def log_error(cls, message: str) -> 'ServerLog':
|
|
"""Create an error level log entry.
|
|
|
|
Args:
|
|
message: Log message
|
|
|
|
Returns:
|
|
ServerLog instance
|
|
"""
|
|
log = cls(level='error', message=message)
|
|
db.session.add(log)
|
|
db.session.commit()
|
|
return log
|