security/acme-client: add support for acme.sh deploy hook "fritzbox"

This commit is contained in:
Frank Wall
2021-11-12 23:35:37 +01:00
parent 5f52f3869e
commit d1907f9613
4 changed files with 86 additions and 1 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ Plugin Changelog
3.5
Added:
* add support for Synology DSM deploy hook (#2236)
* new automation: cert upload to Synology DSM (#2236)
* new automation: cert upload to FRITZ!Box router
Changed:
* refactor code to support acme.sh deploy hooks
@@ -199,4 +199,25 @@
<type>checkbox</type>
<help>This option ensures that a new certificate is created in Synology DSM if it does not exist yet. If unchecked only existing certificates will be updated.</help>
</field>
<field>
<label>Required Parameters</label>
<type>header</type>
<style>method_table method_table_acme_fritzbox</style>
</field>
<field>
<id>action.acme_fritzbox_url</id>
<label>FRITZ!Box URL</label>
<type>text</type>
<help>URL of the router, i.e. https://fritzbox.example.com.</help>
</field>
<field>
<id>action.acme_fritzbox_username</id>
<label>Username</label>
<type>text</type>
</field>
<field>
<id>action.acme_fritzbox_password</id>
<label>Password</label>
<type>password</type>
</field>
</form>
@@ -0,0 +1,47 @@
<?php
/*
* Copyright (C) 2021 Frank Wall
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\AcmeClient\LeAutomation;
use OPNsense\AcmeClient\LeAutomationInterface;
/**
* Run acme.sh deploy hook fritzbox
* @package OPNsense\AcmeClient
*/
class AcmeFritzbox extends Base implements LeAutomationInterface
{
public function prepare()
{
$this->acme_env['DEPLOY_FRITZBOX_URL'] = (string)$this->config->acme_fritzbox_url;
$this->acme_env['DEPLOY_FRITZBOX_USERNAME'] = (string)$this->config->acme_fritzbox_username;
$this->acme_env['DEPLOY_FRITZBOX_PASSWORD'] = (string)$this->config->acme_fritzbox_password;
$this->acme_args[] = '--deploy-hook fritzbox';
return true;
}
}
@@ -1047,6 +1047,7 @@
<configd_restart_nginx>Restart Nginx (OPNsense plugin)</configd_restart_nginx>
<configd_upload_highwinds>Upload certificate to Highwinds CDN</configd_upload_highwinds>
<configd_upload_sftp>Upload certificate via SFTP</configd_upload_sftp>
<acme_fritzbox>Upload certificate to FRITZ!Box router</acme_fritzbox>
<acme_synology_dsm>Upload certificate to Synology DSM</acme_synology_dsm>
<configd_generic>System or Plugin Command</configd_generic>
</OptionValues>
@@ -1186,6 +1187,21 @@
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_synology_dsm_deviceid>
<acme_fritzbox_url type="TextField">
<Required>N</Required>
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_fritzbox_url>
<acme_fritzbox_username type="TextField">
<Required>N</Required>
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_fritzbox_username>
<acme_fritzbox_password type="TextField">
<Required>N</Required>
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_fritzbox_password>
</action>
</actions>
</items>