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