diff options
| author | J08nY | 2017-06-18 02:29:00 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-18 02:29:00 +0200 |
| commit | 84292d11348cf0611bc0e363ebeba0bb383f0e11 (patch) | |
| tree | b5ebd3bf83bac47b9c0c69b8dd06aeb11f55a02f /src | |
| parent | 7e59f56c80ca60b14766558dd86d581fb651e59d (diff) | |
| download | mailman-pgp-84292d11348cf0611bc0e363ebeba0bb383f0e11.tar.gz mailman-pgp-84292d11348cf0611bc0e363ebeba0bb383f0e11.tar.zst mailman-pgp-84292d11348cf0611bc0e363ebeba0bb383f0e11.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman_pgp/model/list.py | 11 | ||||
| -rw-r--r-- | src/mailman_pgp/rest/lists.py | 18 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/mailman_pgp/model/list.py b/src/mailman_pgp/model/list.py index 4699599..eccb28a 100644 --- a/src/mailman_pgp/model/list.py +++ b/src/mailman_pgp/model/list.py @@ -1,6 +1,6 @@ """""" -from mailman.config import config as mailman_config +from mailman.config import config as mailman_config, config from mailman.database.types import Enum, SAUnicode from mailman.interfaces.action import Action from mailman.model.mailinglist import MailingList @@ -26,6 +26,7 @@ class EncryptedMailingList(Base): def __init__(self, mlist): super().__init__() self.list_id = mlist.list_id + self._pubkey = None self._key_generator = self._create_generator(mlist) self._key_generator.start() @@ -51,3 +52,11 @@ class EncryptedMailingList(Base): def mlist(self): return mailman_config.db.query(MailingList).filter_by( _list_id=self.list_id).first() + + @property + def pubkey(self): + if self._pubkey is None: + if self._key_fingerprint is None: + return None + self._pubkey = config.gpg.export_keys(self._key_fingerprint) + return self._pubkey diff --git a/src/mailman_pgp/rest/lists.py b/src/mailman_pgp/rest/lists.py index e0d2b0f..312661b 100644 --- a/src/mailman_pgp/rest/lists.py +++ b/src/mailman_pgp/rest/lists.py @@ -1,7 +1,7 @@ """""" from mailman.rest.helpers import ( - child, CollectionMixin, etag, not_found, NotFound, okay) + child, CollectionMixin, etag, not_found, okay) from public import public from mailman_pgp.config import config @@ -41,6 +41,7 @@ class AnEncryptedList(_EncryptedBase): list_id=list_id).first() def on_get(self, request, response): + """/lists/<list_id>""" if self._mlist is None: return not_found() else: @@ -48,7 +49,18 @@ class AnEncryptedList(_EncryptedBase): @child() def key(self, context, segments): + return AListPubkey(self._mlist), [] + + +@public +class AListPubkey: + def __init__(self, mlist): + self._mlist = mlist + + def on_get(self, request, response): + """/lists/<list_id>/key""" if self._mlist is None: - return NotFound(), [] + return not_found() else: - pass + resource = dict(public_key=self._mlist.pubkey) + return okay(response, etag(resource)) |
