server_config.h 3.2 KB

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