Skip to content

Commit

Permalink
Merge 19b2cdf into b81afc6
Browse files Browse the repository at this point in the history
  • Loading branch information
daramousk committed May 6, 2019
2 parents b81afc6 + 19b2cdf commit 552e100
Show file tree
Hide file tree
Showing 16 changed files with 752 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install:
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install pypostcode
- if ! [ "$LINT_CHECK" = "1" ]; then pip install transip acme; fi
# example: dependency
# - git clone https://github.com/OCA/webkit-tools -b ${VERSION} $HOME/webkit-tools

Expand Down
91 changes: 91 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
======================
Letsencrypt Transip NL
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-netherlands/tree/11.0/l10n_nl_letsencrypt_transip_nl
:alt: OCA/l10n-netherlands
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-netherlands-11-0/l10n-netherlands-11-0-l10n_nl_letsencrypt_transip_nl
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/176/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module was written to extend the functionality of letsencrypt module
to support transip.nl DNS challenges.

Upon receiving a challenge of type DNS, this module will automatically create
the relevant DNS record on your domain.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

Go to Settings -> General Settings and fill the required fields under
LetsEncrypt.

Those fields are:
DNS Provider: Set this to TransIP
Login: Set this to the username you use to login to transip.nl
Key: Set this to the private key given to you by tranip.nl in order to use their APIs.
URL: Set the URL of the APIs. Usually api.transip.nl

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-netherlands/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_letsencrypt_transip_nl%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Therp BV

Contributors
~~~~~~~~~~~~

* George Daramouskas <gdaramouskas@therp.nl>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-netherlands <https://github.com/OCA/l10n-netherlands/tree/11.0/l10n_nl_letsencrypt_transip_nl>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models
21 changes: 21 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Letsencrypt Transip NL",
"version": "10.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Administration",
"summary": "Adds support for transip.nl",
"depends": [
"letsencrypt",
],
"data": [
"views/base_config_settings.xml",
],
"application": False,
"external_dependencies": {
'python': ["transip"],
},
}
5 changes: 5 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import base_config_settings
from . import letsencrypt
40 changes: 40 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/models/base_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models


class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'

dns_provider = fields.Selection(
selection_add=[('transip', 'TransIP')],
)
letsencrypt_transip_login = fields.Char()
letsencrypt_transip_key = fields.Text()

@api.model
def default_get(self, field_list):
res = super(BaseConfigSettings, self).default_get(field_list)
ir_config_parameter = self.env['ir.config_parameter']
res.update({
'letsencrypt_transip_login': ir_config_parameter.get_param(
'letsencrypt_transip_login'),
'letsencrypt_transip_key': ir_config_parameter.get_param(
'letsencrypt_transip_key'),
})
return res

@api.multi
def set_default(self):
self.ensure_one()
ir_config_parameter = self.env['ir.config_parameter']
ir_config_parameter.set_param(
'letsencrypt_transip_login',
self.letsencrypt_transip_login,
)
ir_config_parameter.set_param(
'letsencrypt_transip_key',
self.letsencrypt_transip_key,
)
return True
43 changes: 43 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/models/letsencrypt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
import base64
import logging

_logger = logging.getLogger(__name__)

try:
from transip.service.objects import DnsEntry
from transip.service.domain import DomainService
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
except ImportError as err:
_logger.debug(err)


class Letsencrypt(models.AbstractModel):
_inherit = 'letsencrypt'

def _respond_challenge_dns_transip(self, challenge, domain):
"""_respond_challenge_dns_transip Creates the TXT record on TransIP.
:param challenge: An acme.challenges.Challenge object that contains
relevant data for this challenge.
:param domain: A str. The domain that the challenge is for.
"""
ir_config_parameter = self.env['ir.config_parameter']
login = ir_config_parameter.get_param('letsencrypt_transip_login')
key = ir_config_parameter.get_param('letsencrypt_transip_key')
token = base64.urlsafe_b64encode(challenge.token)
dns_entry = DnsEntry('_acme-challenge', 60, 'TXT', token)
key = serialization.load_pem_private_key(
str(key),
password=None,
backend=default_backend())
key = key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption())
domain = domain.split('*.')[-1]
DomainService(login, key).set_dns_entries(domain, [dns_entry])
10 changes: 10 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To configure this module, you need to:

Go to Settings -> General Settings and fill the required fields under
LetsEncrypt.

Those fields are:
DNS Provider: Set this to TransIP
Login: Set this to the username you use to login to transip.nl
Key: Set this to the private key given to you by tranip.nl in order to use their APIs.
URL: Set the URL of the APIs. Usually api.transip.nl
1 change: 1 addition & 0 deletions l10n_nl_letsencrypt_transip_nl/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* George Daramouskas <gdaramouskas@therp.nl>
5 changes: 5 additions & 0 deletions l10n_nl_letsencrypt_transip_nl/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module was written to extend the functionality of letsencrypt module
to support transip.nl DNS challenges.

Upon receiving a challenge of type DNS, this module will automatically create
the relevant DNS record on your domain.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 552e100

Please sign in to comment.