diff --git a/acme/acme/jws.py b/acme/acme/jws.py index 57515f100..894e69f3d 100644 --- a/acme/acme/jws.py +++ b/acme/acme/jws.py @@ -4,12 +4,8 @@ The JWS implementation in josepy only implements the base JOSE standard. In order to support the new header fields defined in ACME, this module defines some ACME-specific classes that layer on top of josepy. """ -import json - import josepy as jose -from acme.challenges import ChallengeResponse - class Header(jose.Header): """ACME-specific JOSE Header. Implements nonce, kid, and url. diff --git a/acme/acme/mixins.py b/acme/acme/mixins.py index 050155dc3..e676c1485 100644 --- a/acme/acme/mixins.py +++ b/acme/acme/mixins.py @@ -1,16 +1,11 @@ -from josepy import JSONObjectWithFields - -from acme.magic_typing import TYPE_CHECKING # pylint: disable=unused-import, no-name-in-module - -if TYPE_CHECKING: - _Base = JSONObjectWithFields -else: - _Base = object +"""Useful mixins for Challenge and Resource objects""" class VersionedLEACMEMixin(object): + """This mixin allows to store the current ACME version as a property""" @property def le_auto_version(self): + """Define the version of ACME protocol to use""" return getattr(self, '_le_auto_version', 1) @le_auto_version.setter @@ -22,16 +17,21 @@ class VersionedLEACMEMixin(object): def __setattr__(self, key, value): if key == 'le_auto_version': - # Needed to allow @property to operate properly. See comment above. + # Required for @property to operate properly. See comment above. object.__setattr__(self, key, value) else: super(VersionedLEACMEMixin, self).__setattr__(key, value) -class ResourceMixin(VersionedLEACMEMixin, _Base): +class ResourceMixin(VersionedLEACMEMixin): + """ + This mixin allows to generate a RFC8555 compliant JWS payload + by removing the `resource` field if needed (eg. ACME v2 protocol). + """ def to_partial_json(self): + """See josepy.JSONDeserializable.to_partial_json()""" if hasattr(super(ResourceMixin, self), 'to_partial_json'): - jobj = super(ResourceMixin, self).to_partial_json() + jobj = super(ResourceMixin, self).to_partial_json() # type: ignore if self.le_auto_version == 2: jobj.pop('resource', None) return jobj @@ -39,10 +39,15 @@ class ResourceMixin(VersionedLEACMEMixin, _Base): raise AttributeError('This class does not implement method to_partial_json().') -class TypeMixin(VersionedLEACMEMixin, _Base): +class TypeMixin(VersionedLEACMEMixin): + """ + This mixin allows to generate a RFC8555 compliant JWS payload + by removing the `type` field if needed (eg. ACME v2 protocol). + """ def to_partial_json(self): + """See josepy.JSONDeserializable.to_partial_json()""" if hasattr(super(TypeMixin, self), 'to_partial_json'): - jobj = super(TypeMixin, self).to_partial_json() + jobj = super(TypeMixin, self).to_partial_json() # type: ignore if self.le_auto_version == 2: jobj.pop('type', None) return jobj diff --git a/certbot-nginx/local-oldest-requirements.txt b/certbot-nginx/local-oldest-requirements.txt index 37532aabf..1782f15ba 100644 --- a/certbot-nginx/local-oldest-requirements.txt +++ b/certbot-nginx/local-oldest-requirements.txt @@ -1,3 +1,3 @@ # Remember to update setup.py to match the package versions below. -acme[dev]==1.0.0 +-e acme[dev] -e certbot[dev]