1 Introduction
2 ------------
3
4 MoinMessage provides a library for creating, signing, encrypting, decrypting,
5 and verifying PGP/GPG content in Python along with mechanisms for updating
6 MoinMoin wiki instances with such content such that contributors can be
7 identified from their PGP signatures and such details used to authenticate
8 their contributions.
9
10 Configuring GPG for a Wiki
11 --------------------------
12
13 Initialise a homedir for GPG and configure it using filesystem ACL (access
14 control list) properties:
15
16 ./scripts/init_wiki_keyring.sh WIKI WEBUSER
17
18 Here, WIKI should be replaced by the top-level wiki instance directory, and
19 WEBUSER should be the name of the user under which the Web server operates.
20
21 Note that this script may need re-running after the homedir has been changed
22 by gpg operations as gpg likes to remove permissions from various files.
23
24 To be in any way useful, signing keys must be made available within this
25 homedir so that incoming messages can have their senders verified.
26
27 To see the keys available to you in your own environment:
28
29 gpg --list-keys --with-fingerprint
30
31 The full fingerprints are used when defining a user mapping in the wiki, and
32 the --with-fingerprint option is used to show them. Otherwise, only the last
33 eight characters of the fingerprints are shown.
34
35 Export the public key used when signing messages from your own environment:
36
37 gpg --armor --output 1C1AAF83.asc --export 1C1AAF83
38
39 Import the key into the wiki's GPG homedir:
40
41 gpg --homedir wiki/gnupg --import 1C1AAF83.asc
42
43 For the wiki to receive encrypted data, a key for the wiki must be created:
44
45 gpg --homedir wiki/gnupg --gen-key
46
47 For the wiki environment to be able to use the key, password access must be
48 disabled. This can be done by either not specifying a password or by removing
49 it later using the --edit-key option.
50
51 Export the wiki's key for encrypting messages sent to the wiki:
52
53 gpg --homedir wiki/gnupg --armor --output 0891463A.asc --export 0891463A
54
55 This exported key can now be imported into your own environment:
56
57 gpg --import 0891463A.asc
58
59 Configuring the Wiki
60 --------------------
61
62 In the wiki configuration, define the following settings:
63
64 moinmessage_gpg_homedir
65 This sets the path to the homedir initialised above.
66
67 moinmessage_gpg_users_page (optional, default is MoinMessageUserDict)
68 This provides a mapping from key fingerprints to Moin usernames.
69
70 moinmessage_gpg_signing_users_page (optional, default is MoinMessageSigningUserDict)
71 This provides a mapping from Moin usernames to key fingerprints.
72
73 moinmessage_gpg_recipients_page (optional, default is MoinMessageRecipientsDict)
74 This provides a mapping from recipients to remote URLs and key fingerprints.
75 Each user can define the named page as a subpage of their own home page.
76 If no such personal mapping exists, a common mapping exists relative to the
77 site root.
78
79 moinmessage_reject_messages_without_dates (optional, default is True)
80 This causes messages sent to a wiki using the PostMessage action to be
81 rejected if date information is missing.
82
83 moinmessage_static_files (optional, may refer to the built-in htdocs directory)
84 This explicitly defines the path to static resources used by Moin, enabling
85 such resources to be attached to messages. When set, the path must refer to
86 the htdocs directory (possibly renamed) containing the different theme
87 resource directories, together with the robots.txt and favicon.ico files.)
88
89 For signature verification to function, the following needs to be added:
90
91 from MoinMoin.auth.pgp import PGPAuth
92
93 This should import an authentication handler installed when the MoinMessage
94 software is installed as an extension package.
95
96 Within the configuration class itself, the auth setting needs to be updated to
97 include PGPAuth in the list of registered handlers. For example:
98
99 auth = [MoinAuth(), PGPAuth()]
100
101 This would permit the traditional Moin authentication and add signature-based
102 authentication so that messages can be accepted by the wiki.
103
104 Fingerprints and Keys
105 ---------------------
106
107 All fingerprints mentioned in the various configuration pages must exclude
108 space characters - that is, the letters and digits must appear together in a
109 continuous block of text - and refer to keys available in the wiki homedir.
110
111 The Fingerprint-to-Username Mapping
112 -----------------------------------
113
114 The mapping from fingerprints to usernames typically defined by the
115 MoinMessageUserDict page is a WikiDict having the following general format:
116
117 fingerprint:: username
118
119 Each fingerprint corresponds to a key used by a person wanting to send
120 messages to the wiki to sign such messages.
121
122 Each username must correspond to a registered user in the wiki.
123
124 The Username-to-Signing Key Mapping
125 -----------------------------------
126
127 The mapping from usernames to fingerprints typically defined by the
128 MoinMessageSigningUserDict page is a WikiDict having the following general
129 format:
130
131 username:: fingerprint
132
133 Each fingerprint corresponds to a key available in the wiki's GPG homedir
134 generated for the purpose of signing the specified user's messages. Such a key
135 is not the same as one used by a person to send messages to the wiki since
136 only the public key is available to the wiki when verifying such messages,
137 whereas the signing of messages requires access to a private key. Thus, the
138 signing process employs a special private key known to the wiki for a user.
139
140 The Recipients Mapping
141 ----------------------
142
143 The mapping from recipients to remote URLs and fingerprints typically defined
144 by the MoinMessageRecipientsDict page is a WikiDict having the following
145 general format:
146
147 recipient:: type location [ fingerprint ]
148
149 Where the type is "page", the accompanying location must be a page name
150 indicating a page that provides a message store that will accept messages.
151
152 Where the type is "url", the accompanying location must be a URL that must
153 itself refer to a resource that can accept MoinMessage content.
154
155 Where a type of "url" has been given, a fingerprint must accompany this
156 information in order to encrypt messages sent to the specified resource.
157
158 Each fingerprint corresponds to a key used by the wiki to encrypt messages and
159 by the remote site (as identified by the URL) to decrypt messages.
160
161 Quick Start: Signing, Encrypting and Sending Messages
162 -----------------------------------------------------
163
164 To send a message signed and encrypted to a resource on localhost:
165
166 python tests/test_send.py 1C1AAF83 0891463A http://localhost/wiki/ShareTest \
167 collection update 'An update to the wiki.' 'Another update.'
168
169 Here, the first identifier is a reference to the signing key (over which you
170 have complete control), and the second identifier is a reference to the
171 encryption key (which is a public key published for the wiki).
172
173 This needs password protection to be removed from the secret key in the Web
174 server environment. It also uses a modified trust model when invoking gpg in
175 order to avoid complaints about the identity of the sender during encryption.
176
177 To sign the encrypted message for forwarding, the above command is modified:
178
179 python tests/test_send.py 1C1AAF83 0891463A --forward 1C1AAF83 \
180 http://localhost/wiki/ShareTest \
181 collection update 'An update to the wiki.' 'Another update.'
182
183 Below, the mechanisms employed are illustrated through the use of the other
184 test programs.
185
186 Signing
187 -------
188
189 Prepare a message signed with a "detached signature" (note that this does not
190 seem to be what gpg calls a detached signature with the --detach-sig option):
191
192 python tests/test_message.py collection update 'An update to the wiki.' \
193 'Another update.' \
194 | python tests/test_sign.py 1C1AAF83
195
196 The complicated recipe based on the individual operations is as follows:
197
198 python tests/test_message.py collection update 'An update to the wiki.' \
199 'Another update.' \
200 > test.txt \
201 && cat test.txt \
202 | gpg --armor -u 1C1AAF83 --detach-sig \
203 | python tests/test_sign_wrap.py test.txt
204
205 Encryption
206 ----------
207
208 Prepare a message with an encrypted payload using the above key:
209
210 python tests/test_message.py collection update 'An update to the wiki.' \
211 'Another update.' \
212 | python tests/test_encrypt.py 0891463A
213
214 The complicated recipe based on the individual operations is as follows:
215
216 python tests/test_message.py collection update 'An update to the wiki.' \
217 'Another update.' \
218 > test.txt \
219 && cat test.txt \
220 | gpg --armor -r 0891463A --encrypt --trust-model always \
221 | python tests/test_encrypt_wrap.py
222
223 Note that "--trust-model always" is used only to avoid prompting issues.
224
225 Signing and Encrypting
226 ----------------------
227
228 Sign and encrypt a message:
229
230 python tests/test_message.py collection update 'An update to the wiki.' \
231 'Another update.' \
232 | python tests/test_sign.py 1C1AAF83 \
233 | python tests/test_encrypt.py 0891463A
234
235 The complicated recipe based on the individual operations is as follows:
236
237 python tests/test_message.py collection update 'An update to the wiki.' \
238 'Another update.' \
239 > test.txt \
240 && cat test.txt \
241 | gpg --armor -u 1C1AAF83 --detach-sig \
242 | python tests/test_sign_wrap.py test.txt \
243 | gpg --armor -r 0891463A --encrypt --trust-model always \
244 | python tests/test_encrypt_wrap.py
245
246 Signing and Encrypting then Signing
247 -----------------------------------
248
249 Where a message is to be forwarded and not decrypted, it will be signed by the
250 author, encrypted, but then signed by the forwarder (perhaps initially the
251 author):
252
253 python tests/test_message.py collection update 'An update to the wiki.' \
254 'Another update.' \
255 | python tests/test_sign.py 1C1AAF83 \
256 | python tests/test_encrypt.py 0891463A \
257 | python tests/test_sign.py 1C1AAF83
258
259 The complicated recipe based on the individual operations is as follows:
260
261 python tests/test_message.py collection update 'An update to the wiki.' \
262 'Another update.' \
263 > test.txt \
264 && cat test.txt \
265 | gpg --armor -u 1C1AAF83 --detach-sig \
266 | python tests/test_sign_wrap.py test.txt \
267 | gpg --armor -r 0891463A --encrypt --trust-model always \
268 | python tests/test_encrypt_wrap.py \
269 > test2.txt \
270 && cat test2.txt \
271 | gpg --armor -u 1C1AAF83 --detach-sig \
272 | python tests/test_sign_wrap.py test2.txt
273
274 Posting a Message
275 -----------------
276
277 To post a signed and/or encrypted message, output from the above activities
278 can be piped into the following command:
279
280 python tests/test_post.py http://localhost/wiki/ShareTest
281
282 Here, the resource "/wiki/ShareTest" on localhost is presented with the
283 message.
284
285 Fetching Messages
286 -----------------
287
288 To fetch messages from a message store associated with a page, the following
289 command can be used:
290
291 python tests/test_fetch.py 1C1AAF83 0891463A http://localhost/wiki/ShareTest \
292 RETR
293
294 This should retrieve all messages from the store associated with the
295 "/wiki/ShareTest" resource on localhost.
296
297 The Message Format
298 ------------------
299
300 Messages are MIME-encoded and consist of one or more update fragments. Where
301 the "Update-Type" header is present and set to a value of "collection", a
302 multipart message describes as many updates as there are parts. Otherwise,
303 only a single update is described by the message.
304
305 For each update, the "Update-Action" header indicates the action to be taken
306 with the update content. Where it is absent, the content is inserted into the
307 wiki page specified in the request; where it is present and set to "replace",
308 the content replaces all content on the wiki page; where it is set to "store",
309 the content is stored in a message store associated with the wiki page.
310
311 Each update may describe multiple representations of some content by employing
312 a multipart/alternative section containing parts for each of the
313 representations. Alternatively, a single message part may describe a single
314 representation.
315
316 HTTP Methods
317 ------------
318
319 Since MoinMoin seems to reserve POST methods for request/entity bodies that
320 contain HTML form data, it is necessary to use alternative methods to post
321 messages to a site served by MoinMoin and to fetch messages from such a site.
322 Consequently, MoinMessage uses PUT to post messages and recommends GET to
323 fetch messages.
324
325 Contact, Copyright and Licence Information
326 ------------------------------------------
327
328 See the following Web page for more information about this work:
329
330 http://moinmo.in/ActionMarket/MoinMessage
331
332 The author can be contacted at the following e-mail address:
333
334 paul@boddie.org.uk
335
336 Copyright and licence information can be found in the docs directory - see
337 docs/COPYING.txt and docs/LICENCE.txt for more information.
338
339 Dependencies
340 ------------
341
342 MoinMessage has the following basic dependencies:
343
344 Packages Release Information
345 -------- -------------------
346
347 MoinSupport Tested with 0.4
348 Source: http://hgweb.boddie.org.uk/MoinSupport