Puppet Class: role::confirmedit

Defined in:
puppet/modules/role/manifests/confirmedit.pp

Overview

Class: role::confirmedit

The ConfirmEdit extension lets you use various different CAPTCHA techniques, to try to prevent spambots and other automated tools from editing your wiki, as well as to foil automated login attempts that try to guess passwords.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'puppet/modules/role/manifests/confirmedit.pp', line 6

class role::confirmedit {
    require ::role::mediawiki

    require_package('fonts-dejavu')
    require_package('python3-pil')
    require_package('wbritish-small')

    $font     = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
    $wordlist = '/usr/share/dict/words'
    $output   = "${::mediawiki::dir}/images/temp/captcha"
    $key      = 'FOO'

    mediawiki::extension { 'ConfirmEdit':
        settings => [
          # Skip captcha for users with confirmed emails
          '$wgGroupPermissions["emailconfirmed"]["skipcaptcha"] = true;',
        ],
    }

    mediawiki::settings { 'ConfirmEdit FancyCaptcha':
        header   => 'wfLoadExtension( "ConfirmEdit/FancyCaptcha" ); $wmvActiveExtensions[] = "FancyCaptcha";',
        values   => {
            wgCaptchaClass           => 'MediaWiki\\Extension\\ConfirmEdit\\FancyCaptcha\\FancyCaptcha',
            wgCaptchaDirectory       => '$IP/images/temp/captcha',
            wgCaptchaDirectoryLevels => 0,
            wgCaptchaSecret          => $key,
        },
        priority => 11,
        require  => MediaWiki::Extension['ConfirmEdit'],
        notify   => Exec['generate_captchas'],
    }

    file { [ "${::mediawiki::dir}/images/temp", $output ]:
        ensure  => directory,
        before  => Exec['generate_captchas'],
        require => Git::Clone['mediawiki/core'],
    }

    exec { 'generate_captchas':
        command     => "/usr/bin/python3 captcha.py --font=${font} --wordlist=${wordlist} --key=${key} --output=${output}",
        cwd         => "${::mediawiki::dir}/extensions/ConfirmEdit",
        require     => [
            Package['wbritish-small'],
            Package['fonts-dejavu'],
        ],
        refreshonly => true,
    }
}