1.1 --- a/MoinMessageSupport.py Wed Oct 16 16:11:30 2013 +0200
1.2 +++ b/MoinMessageSupport.py Wed Oct 16 16:50:48 2013 +0200
1.3 @@ -214,6 +214,14 @@
1.4 getattr(request.cfg, "moinmessage_gpg_signing_users_page", "MoinMessageSigningUserDict"),
1.5 request)
1.6
1.7 +def get_relays(request):
1.8 +
1.9 + "Return a dictionary mapping relays to URLs."
1.10 +
1.11 + return getWikiDict(
1.12 + getattr(request.cfg, "moinmessage_gpg_relays_page", "MoinMessageRelayDict"),
1.13 + request)
1.14 +
1.15 def get_recipients(request):
1.16
1.17 """
2.1 --- a/README.txt Wed Oct 16 16:11:30 2013 +0200
2.2 +++ b/README.txt Wed Oct 16 16:50:48 2013 +0200
2.3 @@ -96,6 +96,10 @@
2.4 their fingerprint-to-user mapping (see moinmessage_gpg_users_page) to be
2.5 able to receive messages from this wiki.
2.6
2.7 + moinmessage_gpg_relays_page (optional, default is MoinMessageRelayDict)
2.8 + Where message relaying is specified for a recipient, the relay name will be
2.9 + looked up in the dictionary provided by this page.
2.10 +
2.11 moinmessage_gpg_recipients_page (optional, default is MoinMessageRecipientsDict)
2.12 This provides a mapping from recipients to remote URLs and key fingerprints.
2.13 Each user can define the named page as a subpage of their own home page.
2.14 @@ -219,8 +223,12 @@
2.15 Where the type is "url", the accompanying location must be a URL that must
2.16 itself refer to a resource that can accept MoinMessage content.
2.17
2.18 -Where a type of "url" has been given, a fingerprint must accompany this
2.19 -information in order to encrypt messages sent to the specified resource.
2.20 +Where the type is "relay", the accompanying location is an identifier that
2.21 +must be defined in the relays mapping (see below) and yield a URL that can
2.22 +accept MoinMessage content.
2.23 +
2.24 +Where a type of "url" or "relay" has been given, a fingerprint must accompany
2.25 +this information in order to encrypt messages sent to the specified resource.
2.26
2.27 Each fingerprint corresponds to a key used by the wiki to encrypt messages and
2.28 by the remote site (as identified by the URL) to decrypt messages.
2.29 @@ -229,6 +237,18 @@
2.30 MoinMessageRecipientsDict unless overridden by the configuration, as a subpage
2.31 of their own home page.
2.32
2.33 +The Relays Mapping
2.34 +------------------
2.35 +
2.36 +The mapping from relay identifiers to remote URLs defined by the
2.37 +MoinMessageRelayDict page is a WikiDict having the following general format:
2.38 +
2.39 + relay:: url
2.40 +
2.41 +The URL must be able to accept MoinMessage content, and it will typically be
2.42 +configured so that the user or entity accepting relayed content on the remote
2.43 +site can store such content for later propagation or retrieval.
2.44 +
2.45 Quick Start: Signing, Encrypting and Sending Messages
2.46 -----------------------------------------------------
2.47
3.1 --- a/actions/SendMessage.py Wed Oct 16 16:11:30 2013 +0200
3.2 +++ b/actions/SendMessage.py Wed Oct 16 16:50:48 2013 +0200
3.3 @@ -12,7 +12,7 @@
3.4 from MoinMoin.Page import Page
3.5 from MoinMoin import config
3.6 from MoinMessage import GPG, MoinMessageError, Message, sendMessage, timestamp
3.7 -from MoinMessageSupport import get_signing_users, get_recipients
3.8 +from MoinMessageSupport import get_signing_users, get_recipients, get_relays
3.9 from MoinSupport import *
3.10 from MoinMoin.wikiutil import escape, MimeType, parseQueryString, \
3.11 taintfilename
3.12 @@ -103,8 +103,6 @@
3.13 "send_selected" : self._get_selected("send", action),
3.14 "queue_label" : escape(_("Queue message for sending")),
3.15 "queue_selected" : self._get_selected("queue", action),
3.16 - "forward_label" : escape(_("Send message for forwarding")),
3.17 - "forward_selected" : self._get_selected("forward", action),
3.18 }
3.19
3.20 # Prepare the output HTML.
3.21 @@ -149,7 +147,6 @@
3.22 <select name="send-action">
3.23 <option value="send" %(send_selected)s>%(send_label)s</option>
3.24 <option value="queue" %(queue_selected)s>%(queue_label)s</option>
3.25 - <option value="forward" %(forward_selected)s>%(forward_label)s</option>
3.26 </select>
3.27 </td>
3.28 </tr>
3.29 @@ -177,7 +174,6 @@
3.30 action = form.get("send-action", ["send"])[0]
3.31
3.32 queue = action == "queue"
3.33 - forward = action == "forward"
3.34
3.35 if not text:
3.36 return 0, _("A message must be given.")
3.37 @@ -293,37 +289,50 @@
3.38 if not parameters.has_key("location"):
3.39 return 0, _("The recipient details are missing a location for sent messages.")
3.40
3.41 - if parameters.get("type") == "url" and not parameters.has_key("fingerprint"):
3.42 + if parameters["type"] in ("url", "relay") and not parameters.has_key("fingerprint"):
3.43 return 0, _("The recipient details are missing a fingerprint for sending messages.")
3.44
3.45 + type = parameters["type"]
3.46 + location = parameters["location"]
3.47 +
3.48 + # Obtain the actual location if a relay is specified.
3.49 +
3.50 + if parameters["type"] == "relay":
3.51 + relays = get_relays(request)
3.52 + if not relays:
3.53 + return 0, _("No relays are defined for MoinMessage, but one is specified for the recipient.")
3.54 + if not relays.has_key(location):
3.55 + return 0, _("The relay specified for the recipient is not defined.")
3.56 +
3.57 + location = relays[location]
3.58 +
3.59 # Sign, encrypt and send the message.
3.60
3.61 message = message.get_payload()
3.62 - type = parameters["type"]
3.63
3.64 - if not queue and type == "url":
3.65 + if not queue and type in ("url", "relay"):
3.66 try:
3.67 if signer:
3.68 message = gpg.signMessage(message, signer)
3.69
3.70 message = gpg.encryptMessage(message, parameters["fingerprint"])
3.71
3.72 - # Add signing for forwarded messages.
3.73 + # Send relayed messages with an extra signature.
3.74
3.75 - relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user")
3.76 + if type == "relay":
3.77 + relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user")
3.78
3.79 - # Signing with the same identity if no special relaying user is
3.80 - # defined.
3.81 + # Signing with the same identity if no special relaying user is
3.82 + # defined.
3.83
3.84 - if relaying_user:
3.85 - signer = signing_users and signing_users.get(relaying_user)
3.86 + if relaying_user:
3.87 + signer = signing_users and signing_users.get(relaying_user)
3.88
3.89 - if forward and signer:
3.90 timestamp(message)
3.91 message["Update-Action"] = "store"
3.92 message = gpg.signMessage(message, signer)
3.93
3.94 - sendMessage(message, parameters["location"])
3.95 + sendMessage(message, location)
3.96
3.97 except MoinMessageError, exc:
3.98 return 0, "%s: %s" % (_("The message could not be prepared and sent"), exc)
3.99 @@ -331,7 +340,7 @@
3.100 # Or queue the message on the specified page.
3.101
3.102 elif type == "page":
3.103 - page = Page(request, parameters["location"])
3.104 + page = Page(request, location)
3.105 outbox = ItemStore(page, "messages", "message-locks")
3.106 outbox.append(message.as_string())
3.107