summaryrefslogtreecommitdiffstats
path: root/modules-available/webinterface/page.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/webinterface/page.inc.php')
-rw-r--r--modules-available/webinterface/page.inc.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/modules-available/webinterface/page.inc.php b/modules-available/webinterface/page.inc.php
index 318dd82c..d21c627e 100644
--- a/modules-available/webinterface/page.inc.php
+++ b/modules-available/webinterface/page.inc.php
@@ -10,7 +10,8 @@ class Page_WebInterface extends Page
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}
- switch (Request::post('action')) {
+ $action = Request::post('action', null, 'string');
+ switch ($action) {
case 'https':
User::assertPermission("edit.https");
$this->actionConfigureHttps();
@@ -23,7 +24,15 @@ class Page_WebInterface extends Page
User::assertPermission("edit.design");
$this->actionCustomization();
break;
+ case 'https-api-key-generate':
+ case 'https-api-key-delete':
+ User::assertPermission("edit.https");
+ $this->handleApiKey(substr($action, 14));
+ break;
default:
+ if ($action !== null) {
+ Message::addWarning('main.invalid-action', $action);
+ }
}
if (Request::isPost()) {
Util::redirect('?do=webinterface');
@@ -154,8 +163,11 @@ class Page_WebInterface extends Page
}
$data['acmeMail'] = Acme::getMail();
$data['acmeDomains'] = $domains;
- $data['acmeKeyId'] = Acme::getKeyId();
- $data['acmeHmacKey'] = Acme::getHmacKey();
+ if (User::hasPermission("edit.https")) {
+ $data['acmeKeyId'] = Acme::getKeyId();
+ $data['acmeHmacKey'] = Acme::getHmacKey();
+ $data['httpsApiKey'] = WebInterface::getApiKey();
+ }
// $type might have changed in above block
$data[$type . 'Selected'] = true;
// Show cert info if possible
@@ -177,6 +189,7 @@ class Page_WebInterface extends Page
$data['certExpireClass'] = implode(' ', $class);
}
}
+ $data['httpsApiKeyPostUrl'] = ($https ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/slx-admin/api.php?do=webinterface';
Permission::addGlobalTags($data['perms'], null, ['edit.https']);
Render::addTemplate('https', $data);
//
@@ -283,5 +296,14 @@ class Page_WebInterface extends Page
return Acme::issueNewCertificate($wipeAll);
}
+ private function handleApiKey(string $substr)
+ {
+ if ($substr === 'generate') {
+ WebInterface::setApiKey(Util::randomUuid());
+ } elseif ($substr === 'delete') {
+ WebInterface::setApiKey(null);
+ }
+ }
+
}