Skip to content

Commit

Permalink
Tag v1.0.0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Callum027 authored Mar 11, 2023
1 parent 6fe284f commit 87a8fb1
Show file tree
Hide file tree
Showing 7 changed files with 691 additions and 747 deletions.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Release
about: Template for creating a checklist issue for a new release.
title: Tag v<new version>
labels: release
assignees: Callum027

---

Checklist:

1. [ ] Set milestone to `v<new version>`
1. [ ] Get the raw changelog using the following command:
```bash
$ git log --oneline --decorate v<previous version>..HEAD
```
1. [ ] Update the `tool.poetry.version` field in `pyproject.toml`
1. [ ] Create pull request: <paste pull request here>
1. [ ] Merge pull request
1. [ ] Check that the CI pipeline passed on `main`: <paste CI workflow here>
1. [ ] Tag the new release
1. [ ] Check that the release was automatically published to PyPI: <paste release workflow here>
1. [ ] Close release milestone
1. [ ] Close this issue
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ repos:
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
rev: "5.12.0"
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: "22.10.0"
rev: "23.1.0"
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: "5.0.4"
rev: "6.0.0"
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.990"
rev: "v1.1.1"
hooks:
- id: mypy
- repo: https://github.com/python-poetry/poetry
rev: "1.2.2"
rev: "1.4.0"
hooks:
- id: poetry-check
- id: poetry-lock
# Disabled 2023-03-12: Do not always update dependencies on commit.
# - id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
34 changes: 15 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,32 @@

A compatibility script between [Lego](https://go-acme.github.io/lego) and [Certbot](https://certbot.eff.org), to allow Lego to use Certbot authenticator plugins to perform `DNS-01` challenges.

Designed to be run using the [exec](https://go-acme.github.io/lego/dns/exec/) provider in `default` mode.
Designed to be run using the [`exec`](https://go-acme.github.io/lego/dns/exec) provider in `default` mode.

## Installing
## Installation

`lego-certbot` can be directly installed using `pip`.
The latest version of `lego-certbot` can be directly installed using `pip`.

```
$ python3 -m pip install "lego-certbot @ https://github.com/Callum027/lego-certbot/archive/refs/tags/v0.3.0.zip"
$ python3 -m pip install lego-certbot
```

Available extras:

* `metaname` - install the [certbot-dns-metaname](https://github.com/Callum027/certbot-dns-metaname/tree/stateless-cleanup) DNS authenticator

The repository contains a fixed `requirements.txt` with known working package versions, and a virtual environment can be created based on that.
If you'd prefer to clone the `lego-certbot` repository directly, you can install it as a local package in a virtual environment.

```
$ git clone -b v0.3.0 https://github.com/Callum027/lego-certbot.git
$ git clone https://github.com/Callum027/lego-certbot.git
$ cd lego-certbot
$ python3 -m .venv
$ python3 -m venv .venv
$ source .venv/bin/activate
$ python3 -m pip install -r requirements.txt .
```

Or, if you have Poetry installed, you can setup the virtual environment using `poetry install`.
`lego-certbot` uses Poetry, so it is recommended to setup a development environment using `poetry install`.

```
$ git clone -b v0.3.0 https://github.com/Callum027/lego-certbot.git
$ git clone https://github.com/Callum027/lego-certbot.git
$ cd lego-certbot
$ poetry install [--with=metaname]
$ poetry install [--with=dev]
```

## Configuration
Expand Down Expand Up @@ -71,19 +67,19 @@ optional arguments:
-v, --version show program's version number and exit
```

Instead, `lego-certbot` itself is configured using the following environment variables.\
It also shows an configuration for [the third party Metaname DNS authenticator](https://github.com/Callum027/certbot-dns-metaname/tree/stateless-cleanup) as an example of how to use them.
Instead, `lego-certbot` itself is configured using the following environment variables:

* `LEGOCERTBOT_DOMAIN` - The root domain name of the (sub)domain for which the ACME challenge will take place.
* `LEGOCERTBOT_DOMAIN` - The root domain name of the (sub)domain for which the ACME challenge will take place.\
Example: `example.com`
* `LEGOCERTBOT_AUTHENTICATOR_TYPE` - The [DNS authenticator plugin](https://eff-certbot.readthedocs.io/en/stable/using.html#dns-plugins) to use.\
Example: `dns-metaname`

* `LEGOCERTBOT_AUTHENTICATOR_CONFIG` - Parameters to pass to the authenticator, in JSON format.\
Example: `{"endpoint":"https://metaname.net/api/1.1","credentials":"/etc/traefik/metaname.ini"}`

## Usage

Below are some examples of how to integrate `lego-certbot` into your Lego workflow, using [the Metaname DNS authenticator](https://github.com/Callum027/certbot-dns-metaname) as the Certbot authenticator.

### Lego

A complete invocation of Lego to generate a wildcard certificate would look something like this.
Expand Down Expand Up @@ -141,7 +137,7 @@ certificatesResolvers:
- "103.11.126.244:53"
# During development, uncomment the following line to use the Let's Encrypt staging server.
# Necessary to avoid hitting the rate limits on the production servers.
# caServer: https://acme-staging-v02.api.letsencrypt.org/directory
caServer: https://acme-staging-v02.api.letsencrypt.org/directory
```
[Dynamic configuration](https://doc.traefik.io/traefik/getting-started/configuration-overview/#the-dynamic-configuration) (`file` provider):
Expand Down
51 changes: 29 additions & 22 deletions lego_certbot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# lego-certbot
# A compatibility script between Lego and Certbot, to allow Lego to
# use Certbot authenticator plugins to perform DNS-01 challenges.
# Designed to be run using the 'exec' provider in 'default' mode.

"""
A compatibility script between Lego and Certbot, to allow Lego to use
Certbot authenticator plugins to perform DNS-01 challenges.
Designed to be run using the 'exec' provider in 'default' mode.
"""


from __future__ import annotations
Expand All @@ -14,16 +17,22 @@
import sys

from argparse import ArgumentParser, Namespace, RawTextHelpFormatter
from importlib.metadata import entry_points
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, cast

from certbot.configuration import NamespaceConfig
from importlib_metadata import PackageNotFoundError, entry_points
from importlib_metadata import version as package_version

if TYPE_CHECKING:
from typing import Type

from certbot.interfaces import DNSAuthenticator
from certbot.plugins.dns_common import DNSAuthenticator


__version__ = "0.3.0"
try:
__version__ = package_version("lego-certbot")
except PackageNotFoundError:
__version__ = "0.0.0"


def main() -> int:
Expand Down Expand Up @@ -109,22 +118,20 @@ def main() -> int:

# Read the Certbot plugin entry points to find the authenticator's entry,
# and import the class directly.
# Note: importlib.metadata was a provisional library from
# Python 3.8 until Python 3.10, and the original
# entrypoint querying method was deprecated from 3.10 onwards.
if sys.version_info >= (3, 10):
(authenticator_ep,) = entry_points(
group="certbot.plugins",
name=authenticator_module_name,
)
authenticator_class: Type[DNSAuthenticator] = authenticator_ep.load()
else:
authenticator_class = [
ep for ep in entry_points()["certbot.plugins"] if ep.name == authenticator_module_name
][0].load()
# Note: importlib.metadata was a provisional library from Python 3.8 until Python 3.10,
# and the original entrypoint querying method was deprecated from 3.10 onwards.
# Until Python 3.8 and 3.9 are EOL, use the backport importlib-metadata library.
(authenticator_ep,) = entry_points(
group="certbot.plugins",
name=authenticator_module_name,
)
authenticator_class: Type[DNSAuthenticator] = authenticator_ep.load()

# Create an authenticator object to operate against.
authenticator = authenticator_class(authenticator_config, authenticator_config_prefix)
authenticator = authenticator_class(
cast(NamespaceConfig, authenticator_config),
authenticator_config_prefix,
)

# For the 'timeout' command, return the configured timeout and
# poll interval as a JSON object.
Expand Down
Loading

0 comments on commit 87a8fb1

Please sign in to comment.