mirror of
https://github.com/jeffcaldwellca/mkcertWeb.git
synced 2026-02-13 17:28:57 -06:00
4.6 KiB
4.6 KiB
Settings Feature Implementation Summary
Overview
Implemented a comprehensive settings management system that allows configuration of all mkcert Web UI options through a web interface. Settings are persisted to config/settings.json and override .env file values.
Files Created
Frontend
- public/settings.html - Settings page with tabbed interface for all configuration categories
- public/settings.js - Frontend JavaScript for form handling, API calls, and validation
- SETTINGS.md - Comprehensive documentation for the settings feature
Backend
- src/routes/settings.js - REST API endpoints for reading/saving settings
- GET /api/settings - Retrieve current settings
- POST /api/settings - Save settings
- DELETE /api/settings - Reset to defaults
- GET /api/settings/export - Export settings as JSON
- POST /api/settings/import - Import settings from JSON
Configuration
- config/ - Directory for settings.json storage
Files Modified
Configuration System
- src/config/index.js
- Added settings.json loader
- Implemented deep merge function
- Settings.json values override .env values
Server Integration
- server.js
- Imported settings routes
- Mounted settings routes at /api/settings
Navigation
-
public/index.html
- Added Settings link to navigation
- Simplified email/monitoring configuration section (moved config to settings page)
-
public/scep.html
- Added Settings link to navigation
Styling
- public/styles.css
- Added .alert-info style for informational alerts
Version Control
- .gitignore
- Added config/settings.json to prevent committing sensitive data
Features Implemented
Settings Categories
-
Server Configuration
- HTTP/HTTPS ports
- SSL domain
- HTTPS enable/force options
- Certificate directory paths
-
Authentication
- Basic auth (username, password, session secret)
- OIDC SSO (issuer, client ID, client secret, callback URL, scopes)
-
Rate Limiting
- CLI rate limits
- API rate limits
- Auth rate limits
-
Email Notifications
- SMTP configuration
- TLS/SSL settings
- From/To addresses
- Email subject customization
-
Certificate Monitoring
- Enable/disable monitoring
- Cron schedule
- Warning/critical thresholds
- Include uploaded certificates option
-
Theme
- Default theme mode
- Primary color
- Dark mode preference
Security Features
- Sensitive fields (passwords, secrets) are masked when retrieved
- Placeholder values (********) are not saved unless explicitly changed
- Authentication required for settings access (if enabled)
- Rate limiting applied to all settings endpoints
- Settings file excluded from version control
User Experience
- Tabbed interface for organized settings
- Real-time form validation
- Success/error notifications
- Auto-save feedback
- Reset to defaults functionality
- Import/export for backup/restore
Override Mechanism
Configuration priority (highest to lowest):
- config/settings.json (UI settings)
- .env file (environment variables)
- Default values (hardcoded in src/config/index.js)
The deep merge function ensures that UI settings override .env values at any nesting level.
Testing Checklist
- Settings page loads correctly
- Tab navigation works
- Form fields populate from current config
- Settings save successfully
- Settings persist after server restart
- Settings override .env values
- Sensitive fields are masked
- Reset to defaults works
- Navigation links work on all pages
- Authentication applies to settings page
- Rate limiting applies to settings endpoints
Usage Instructions
- Access Settings: Click "Settings" in the navigation menu
- Modify Settings: Edit fields in any tab
- Save: Click "Save Settings" button
- Restart: Restart server for certain changes to take effect
- Reset: Click "Reset to Defaults" to revert all changes
Notes for Deployment
- Ensure
config/directory has write permissions - Review settings after deployment
- Backup
config/settings.jsonbefore major changes - Some settings (ports, HTTPS) require server restart
- Settings file is gitignored - deploy settings separately or use .env
Future Enhancements
Potential improvements for future versions:
- Live reload without server restart for certain settings
- Settings validation on the backend
- Settings change history/audit log
- Bulk import/export of multiple configurations
- Settings templates for common scenarios
- Environment-specific settings (dev, staging, prod)