[FIX] letsencrypt: adapt to conventions.

Get rid of unneeded decorators;
Remove copyright lines from init files;
Replace copyright symbol with text;
Use https: where possible.
pull/2917/head
Ronald Portier 2020-11-19 15:57:20 +01:00 committed by Holger Brunn
parent 5fc34b5fd6
commit a5ba0d8a83
11 changed files with 19 additions and 33 deletions

View File

@ -1,5 +1,4 @@
# © 2016 Therp BV <http://therp.nl> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models
from . import controllers from . import controllers
from .hooks import post_init_hook from .hooks import post_init_hook

View File

@ -16,5 +16,7 @@
"demo": ["demo/ir_cron.xml"], "demo": ["demo/ir_cron.xml"],
"post_init_hook": "post_init_hook", "post_init_hook": "post_init_hook",
"installable": True, "installable": True,
"external_dependencies": {"python": ["acme", "cryptography", "dns", "josepy"]}, "external_dependencies": {
"python": ["acme", "cryptography", "dnspython", "josepy"]
},
} }

View File

@ -1,3 +1,2 @@
# © 2016 Therp BV <http://therp.nl> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import main from . import main

View File

@ -1,7 +1,7 @@
# © 2016 Therp BV <http://therp.nl> # Copyright 2016 Therp BV <https://therp.nl>.
# © 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> # Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>.
# © 2018 Ignacio Ibeas <ignacio@acysos.com> # Copyright 2018 Ignacio Ibeas <ignacio@acysos.com>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import os import os
from odoo import http from odoo import http

View File

@ -1,5 +1,5 @@
# © 2016 Therp BV <http://therp.nl> # Copyright 2016-2020 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import SUPERUSER_ID, api from odoo import SUPERUSER_ID, api

View File

@ -1,4 +1,3 @@
# © 2016 Therp BV <http://therp.nl> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import letsencrypt from . import letsencrypt
from . import res_config_settings from . import res_config_settings

View File

@ -74,7 +74,6 @@ class Letsencrypt(models.AbstractModel):
_name = "letsencrypt" _name = "letsencrypt"
_description = "Abstract model providing functions for letsencrypt" _description = "Abstract model providing functions for letsencrypt"
@api.model
def _generate_key(self): def _generate_key(self):
"""Generate an entirely new key.""" """Generate an entirely new key."""
return rsa.generate_private_key( return rsa.generate_private_key(
@ -87,7 +86,6 @@ class Letsencrypt(models.AbstractModel):
encryption_algorithm=serialization.NoEncryption(), encryption_algorithm=serialization.NoEncryption(),
) )
@api.model
def _get_key(self, key_name): def _get_key(self, key_name):
"""Get a key for a filename, generating if if it doesn't exist.""" """Get a key for a filename, generating if if it doesn't exist."""
key_file = os.path.join(_get_data_dir(), key_name) key_file = os.path.join(_get_data_dir(), key_name)
@ -109,7 +107,6 @@ class Letsencrypt(models.AbstractModel):
key_bytes = file_.read() key_bytes = file_.read()
return key_bytes return key_bytes
@api.model
def _validate_domain(self, domain): def _validate_domain(self, domain):
"""Validate that a domain is publicly accessible.""" """Validate that a domain is publicly accessible."""
if ":" in domain or all(char.isdigit() or char == "." for char in domain): if ":" in domain or all(char.isdigit() or char == "." for char in domain):
@ -122,7 +119,6 @@ class Letsencrypt(models.AbstractModel):
_("Domain %s: Let's encrypt doesn't work with local domains!") % domain _("Domain %s: Let's encrypt doesn't work with local domains!") % domain
) )
@api.model
def _should_run(self, cert_file, domains): def _should_run(self, cert_file, domains):
"""Inspect the existing certificate to see if action is necessary.""" """Inspect the existing certificate to see if action is necessary."""
domains = set(domains) domains = set(domains)
@ -290,7 +286,6 @@ class Letsencrypt(models.AbstractModel):
else: else:
_logger.warning("No reload command defined.") _logger.warning("No reload command defined.")
@api.model
def _wait_for_record(self, domain, token): def _wait_for_record(self, domain, token):
"""Wait until a TXT record for a domain is visible.""" """Wait until a TXT record for a domain is visible."""
if not domain.endswith("."): if not domain.endswith("."):
@ -330,7 +325,6 @@ class Letsencrypt(models.AbstractModel):
net = acme.client.ClientNetwork(account_key) net = acme.client.ClientNetwork(account_key)
return acme.client.ClientV2(directory_json, net) return acme.client.ClientV2(directory_json, net)
@api.model
def _cascade_domains(self, domains): def _cascade_domains(self, domains):
"""Remove domains that are obsoleted by wildcard domains in the list. """Remove domains that are obsoleted by wildcard domains in the list.
@ -367,7 +361,6 @@ class Letsencrypt(models.AbstractModel):
return [urllib.parse.urlparse(base_url).hostname] return [urllib.parse.urlparse(base_url).hostname]
return re.split("(?:,|\n| |;)+", altnames) return re.split("(?:,|\n| |;)+", altnames)
@api.model
def _respond_challenge_http(self, challenge, account_key): def _respond_challenge_http(self, challenge, account_key):
""" """
Respond to the HTTP challenge by writing the file to serve. Respond to the HTTP challenge by writing the file to serve.
@ -391,7 +384,6 @@ class Letsencrypt(models.AbstractModel):
dns_function = getattr(self, "_respond_challenge_dns_" + provider) dns_function = getattr(self, "_respond_challenge_dns_" + provider)
dns_function(domain.replace("*.", ""), token) dns_function(domain.replace("*.", ""), token)
@api.model
def _call_cmdline(self, cmdline, env=None): def _call_cmdline(self, cmdline, env=None):
"""Call a shell command.""" """Call a shell command."""
process = subprocess.Popen( process = subprocess.Popen(
@ -430,7 +422,6 @@ class Letsencrypt(models.AbstractModel):
else: else:
raise UserError(_("No shell command configured for updating DNS records")) raise UserError(_("No shell command configured for updating DNS records"))
@api.model
def _base64_encode(self, data): def _base64_encode(self, data):
"""Encode data as a URL-safe base64 string without padding. """Encode data as a URL-safe base64 string without padding.

View File

@ -1,5 +1,5 @@
# Copyright 2018 Therp BV <http://therp.nl> # Copyright 2018-2020 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, exceptions, fields, models from odoo import _, api, exceptions, fields, models
@ -79,12 +79,9 @@ class ResConfigSettings(models.TransientModel):
) )
return res return res
@api.multi
def set_values(self): def set_values(self):
super().set_values() super().set_values()
self.letsencrypt_check_dns_required() self.letsencrypt_check_dns_required()
if self.letsencrypt_dns_provider == "shell": if self.letsencrypt_dns_provider == "shell":
lines = [ lines = [
line.strip() for line in self.letsencrypt_dns_shell_script.split("\n") line.strip() for line in self.letsencrypt_dns_shell_script.split("\n")

View File

@ -1,4 +1,3 @@
# Copyright 2018 Therp BV <http://therp.nl> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_http from . import test_http
from . import test_letsencrypt from . import test_letsencrypt

View File

@ -1,5 +1,5 @@
# Copyright 2020 Therp BV <http://therp.nl> # Copyright 2020 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import os import os
import shutil import shutil

View File

@ -1,5 +1,5 @@
# Copyright 2018 Therp BV <http://therp.nl> # Copyright 2018-2020 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import os import os
import shutil import shutil