diff options
Diffstat (limited to 'modules-available/webinterface/inc/webinterface.inc.php')
-rw-r--r-- | modules-available/webinterface/inc/webinterface.inc.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules-available/webinterface/inc/webinterface.inc.php b/modules-available/webinterface/inc/webinterface.inc.php index 6dfd924f..276110eb 100644 --- a/modules-available/webinterface/inc/webinterface.inc.php +++ b/modules-available/webinterface/inc/webinterface.inc.php @@ -9,6 +9,8 @@ class WebInterface public const PROP_REDIRECT_DOMAIN = 'webinterface.redirect-domain'; + public const PROP_API_KEY = 'webinterface.api-key'; + /** * Read data all handled domains from current certificate. * SAN takes precedence, if empty, we fall back to CN. @@ -62,4 +64,50 @@ class WebInterface return !empty(Property::get(self::PROP_REDIRECT_DOMAIN, false)); } + public static function isHttpsRedirectEnabled(): bool + { + return Property::get(self::PROP_REDIRECT) === 'True'; + } + + public static function tmDisableHttps(): ?string + { + Property::set(WebInterface::PROP_TYPE, 'off'); + Property::set(WebInterface::PROP_HSTS, 'off'); + $task = Taskmanager::submit('LighttpdHttps', []); + return $task['id'] ?? null; + } + + public static function tmGenerateRandomCert(): ?string + { + Property::set(WebInterface::PROP_TYPE, 'generated'); + $task = Taskmanager::submit('LighttpdHttps', [ + 'proxyip' => Property::getServerIp(), + 'redirect' => self::isHttpsRedirectEnabled(), + ]); + return $task['id'] ?? null; + } + + public static function tmImportCustomCert(string $key, string $cert, ?string $chain = null): ?string + { + Property::set(WebInterface::PROP_TYPE, 'supplied'); + $task = Taskmanager::submit('LighttpdHttps', [ + 'importcert' => $cert, + 'importkey' => $key, + 'importchain' => $chain, + 'redirect' => self::isHttpsRedirectEnabled(), + ]); + return $task['id'] ?? null; + } + + public static function tmSetHttpRedirectMode(): ?string + { + if (Property::get(WebInterface::PROP_TYPE) === 'off') + return null; + $task = Taskmanager::submit('LighttpdHttps', array( + 'redirectOnly' => true, + 'redirect' => self::isHttpsRedirectEnabled(), + )); + return $task['id'] ?? null; + } + }
\ No newline at end of file |