server_config.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef SERVER_CONFIG_H
  2. #define SERVER_CONFIG_H
  3. #include <string>
  4. #include <vector>
  5. /**
  6. * @brief Authentication method enumeration
  7. */
  8. enum class AuthMethod {
  9. NONE, ///< No authentication required
  10. JWT, ///< JWT token authentication
  11. API_KEY, ///< API key authentication
  12. UNIX, ///< Unix system authentication
  13. OPTIONAL ///< Authentication optional (guest access allowed)
  14. };
  15. /**
  16. * @brief Authentication configuration structure
  17. */
  18. struct AuthConfig {
  19. AuthMethod authMethod = AuthMethod::NONE; ///< Primary authentication method
  20. bool enableGuestAccess = false; ///< Allow unauthenticated access
  21. std::string jwtSecret = ""; ///< JWT secret key (auto-generated if empty)
  22. int jwtExpirationMinutes = 60; ///< JWT token expiration in minutes
  23. std::string authRealm = "stable-diffusion-rest"; ///< Authentication realm
  24. std::string dataDir = "./auth"; ///< Directory for authentication data
  25. bool enableUnixAuth = false; ///< Enable Unix authentication
  26. std::vector<std::string> publicPaths; ///< Paths that don't require authentication
  27. std::vector<std::string> adminPaths; ///< Paths that require admin access
  28. std::vector<std::string> userPaths; ///< Paths that require user access
  29. };
  30. // Server configuration structure
  31. struct ServerConfig {
  32. // Server settings
  33. std::string host = "0.0.0.0";
  34. int port = 8080;
  35. int maxConcurrentGenerations = 1;
  36. bool verbose = false;
  37. // Required directory parameter
  38. std::string modelsDir = ""; // Base models directory (required, must be set via --models-dir)
  39. // Model type directory parameters
  40. // All default to standard folder names under modelsDir if not explicitly set
  41. std::string checkpoints = ""; // Checkpoints directory (default: checkpoints)
  42. std::string controlnetDir = ""; // ControlNet directory (default: controlnet)
  43. std::string embeddingsDir = ""; // Embeddings directory (default: embeddings)
  44. std::string esrganDir = ""; // ESRGAN directory (default: ESRGAN)
  45. std::string loraDir = ""; // LoRA directory (default: loras)
  46. std::string taesdDir = ""; // TAESD directory (default: TAESD)
  47. std::string vaeDir = ""; // VAE directory (default: vae)
  48. // Queue and output directories
  49. std::string queueDir = "./queue"; // Directory to store queue job files
  50. std::string outputDir = "./output"; // Directory to store generated images/videos
  51. // UI directory (optional - for serving static web UI)
  52. std::string uiDir = ""; // Directory containing static web UI files
  53. // Legacy mode flag (always false now - kept for backward compatibility)
  54. bool legacyMode = false;
  55. // Logging options
  56. bool enableFileLogging = false;
  57. std::string logFilePath = "/var/log/stable-diffusion-rest/server.log";
  58. // Authentication configuration
  59. AuthConfig auth;
  60. };
  61. #endif // SERVER_CONFIG_H