| 1 |
MediaWiki |
| 2 |
========= |
| 3 |
|
| 4 |
|image0| |
| 5 |
|
| 6 |
Presentation |
| 7 |
------------ |
| 8 |
|
| 9 |
`MediaWiki <http://www.mediawiki.org>`__ is a wiki software, used by the |
| 10 |
well known `Wikipedia <http://www.wikipedia.org>`__. |
| 11 |
|
| 12 |
Several extensions allows one to configure SSO on MediaWiki: |
| 13 |
|
| 14 |
- `Automatic |
| 15 |
REMOTE_USER <http://www.mediawiki.org/wiki/Extension:AutomaticREMOTE_USER>`__ |
| 16 |
- `Siteminder |
| 17 |
Authentication <http://www.mediawiki.org/wiki/Extension:Siteminder_Authentication>`__ |
| 18 |
|
| 19 |
We will explain how to use `Automatic |
| 20 |
REMOTE_USER <http://www.mediawiki.org/wiki/Extension:AutomaticREMOTE_USER>`__ |
| 21 |
extension. |
| 22 |
|
| 23 |
Installation |
| 24 |
------------ |
| 25 |
|
| 26 |
The extension is presented here: |
| 27 |
http://www.mediawiki.org/wiki/Extension:AutomaticREMOTE_USER |
| 28 |
|
| 29 |
You can download the code here: |
| 30 |
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/Auth_remoteuser |
| 31 |
|
| 32 |
You have to install '' Auth_remoteuser'' in the ``extensions/`` |
| 33 |
directory of your MediaWiki installation: |
| 34 |
|
| 35 |
:: |
| 36 |
|
| 37 |
cp -a Auth_remoteuser/ extensions/ |
| 38 |
|
| 39 |
Configuration |
| 40 |
------------- |
| 41 |
|
| 42 |
MediWiki local configuration |
| 43 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 |
|
| 45 |
Then edit MediaWiki local settings |
| 46 |
|
| 47 |
:: |
| 48 |
|
| 49 |
vi LocalSettings.php |
| 50 |
|
| 51 |
.. code-block:: php |
| 52 |
|
| 53 |
require_once "$IP/extensions/Auth_remoteuser/Auth_remoteuser.php"; |
| 54 |
$wgAuth = new Auth_remoteuser(); |
| 55 |
|
| 56 |
Add then extension configuration, for example: |
| 57 |
|
| 58 |
.. code-block:: php |
| 59 |
|
| 60 |
$wgAuthRemoteuserAuthz = true; /* Your own authorization test */ |
| 61 |
$wgAuthRemoteuserName = $_SERVER["HTTP_AUTH_CN"]; /* User's name */ |
| 62 |
$wgAuthRemoteuserMail = $_SERVER["HTTP_AUTH_MAIL"]; /* User's Mail */ |
| 63 |
$wgAuthRemoteuserNotify = false; /* Do not send mail notifications */ |
| 64 |
//$wgAuthRemoteuserDomain = "NETBIOSDOMAIN"; /* Remove NETBIOSDOMAIN\ from the beginning or @NETBIOSDOMAIN at the end of a IWA username */ |
| 65 |
/* User's mail domain to append to the user name to make their email address */ |
| 66 |
//$wgAuthRemoteuserMailDomain = "example.com"; |
| 67 |
|
| 68 |
// see http://www.mediawiki.org/wiki/Manual:Hooks/SpecialPage_initList |
| 69 |
// and http://www.mediawiki.org/w/Manual:Special_pages |
| 70 |
// and http://lists.wikimedia.org/pipermail/mediawiki-l/2009-June/031231.html |
| 71 |
// disable login and logout functions for all users |
| 72 |
function LessSpecialPages(&$list) { |
| 73 |
unset( $list['Userlogout'] ); |
| 74 |
unset( $list['Userlogin'] ); |
| 75 |
return true; |
| 76 |
} |
| 77 |
$wgHooks['SpecialPage_initList'][]='LessSpecialPages'; |
| 78 |
|
| 79 |
// http://www.mediawiki.org/wiki/Extension:Windows_NTLM_LDAP_Auto_Auth |
| 80 |
// remove login and logout buttons for all users |
| 81 |
function StripLogin(&$personal_urls, &$wgTitle) { |
| 82 |
unset( $personal_urls["login"] ); |
| 83 |
unset( $personal_urls["logout"] ); |
| 84 |
unset( $personal_urls['anonlogin'] ); |
| 85 |
return true; |
| 86 |
} |
| 87 |
$wgHooks['PersonalUrls'][] = 'StripLogin'; |
| 88 |
|
| 89 |
|
| 90 |
.. danger:: |
| 91 |
|
| 92 |
In last version of Auth_remoteuser and Mediawiki, empty |
| 93 |
passwords are not authorized, so you may need to patch the extension |
| 94 |
code if you get the error: "Unexpected REMOTE_USER authentication |
| 95 |
failure. Login Error was:EmptyPass". If necessary, use the code |
| 96 |
below to patch the extension: |
| 97 |
|
| 98 |
:: |
| 99 |
|
| 100 |
sed -i "s/'wpPassword' => ''/'wpPassword' => 'none'/" extensions/Auth_remoteuser/Auth_remoteuser.body.php |
| 101 |
|
| 102 |
|
| 103 |
.. danger:: |
| 104 |
|
| 105 |
In last version of Auth_remoteuser and Mediawiki, |
| 106 |
auto-provisioning requires REMOTE_USER to match the normalized mediawiki |
| 107 |
username (for example: john_doe -> john doe), so you may need to patch |
| 108 |
the extension code if you get the error: "Unexpected REMOTE_USER |
| 109 |
authentication failure. Login Error was:WrongPluginPass" You can |
| 110 |
use the code below for normalizing logins containing "_" in the |
| 111 |
extension: |
| 112 |
|
| 113 |
:: |
| 114 |
|
| 115 |
sed -i '/$usertest = $this->getRemoteUsername();/a\ $usertest = str_replace( "_"," ", $usertest );' extensions/Auth_remoteuser/Auth_remoteuser.body.php |
| 116 |
|
| 117 |
MediaWiki virtual host |
| 118 |
~~~~~~~~~~~~~~~~~~~~~~ |
| 119 |
|
| 120 |
Configure MediaWiki virtual host like other |
| 121 |
:doc:`protected virtual host<../configvhost>`. |
| 122 |
|
| 123 |
|
| 124 |
.. attention:: |
| 125 |
|
| 126 |
If you are protecting MediaWiki with LL::NG as reverse |
| 127 |
proxy, |
| 128 |
:doc:`convert header into REMOTE_USER environment variable<../header_remote_user_conversion>`. |
| 129 |
|
| 130 |
- For Apache: |
| 131 |
|
| 132 |
.. code-block:: apache |
| 133 |
|
| 134 |
<VirtualHost *:80> |
| 135 |
ServerName mediawiki.example.com |
| 136 |
|
| 137 |
PerlHeaderParserHandler Lemonldap::NG::Handler |
| 138 |
|
| 139 |
... |
| 140 |
|
| 141 |
</VirtualHost> |
| 142 |
|
| 143 |
- For Nginx: |
| 144 |
|
| 145 |
.. code-block:: nginx |
| 146 |
|
| 147 |
server { |
| 148 |
listen 80; |
| 149 |
server_name mediawiki.example.com; |
| 150 |
root /path/to/application; |
| 151 |
# Internal authentication request |
| 152 |
location = /lmauth { |
| 153 |
internal; |
| 154 |
include /etc/nginx/fastcgi_params; |
| 155 |
fastcgi_pass unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock; |
| 156 |
# Drop post data |
| 157 |
fastcgi_pass_request_body off; |
| 158 |
fastcgi_param CONTENT_LENGTH ""; |
| 159 |
# Prevent attacks on older Nginx versions (<1.29.5) |
| 160 |
fastcgi_param HTTP_HOST $host; |
| 161 |
# Keep original request (LL::NG server will receive /lmauth) |
| 162 |
fastcgi_param X_ORIGINAL_URI $original_uri; |
| 163 |
} |
| 164 |
|
| 165 |
# Client requests |
| 166 |
location / { |
| 167 |
auth_request /lmauth; |
| 168 |
set $original_uri $uri$is_args$args; |
| 169 |
auth_request_set $lmremote_user $upstream_http_lm_remote_user; |
| 170 |
auth_request_set $lmlocation $upstream_http_location; |
| 171 |
error_page 401 $lmlocation; |
| 172 |
try_files $uri $uri/ =404; |
| 173 |
|
| 174 |
... |
| 175 |
|
| 176 |
include /etc/lemonldap-ng/nginx-lua-headers.conf; |
| 177 |
} |
| 178 |
location / { |
| 179 |
try_files $uri $uri/ =404; |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
MediaWiki virtual host in Manager |
| 184 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 185 |
|
| 186 |
Go to the Manager and :doc:`create a new virtual host<../configvhost>` |
| 187 |
for MediaWiki. |
| 188 |
|
| 189 |
Just configure the :ref:`access rules<rules>`. You |
| 190 |
can also add a rule for logout: |
| 191 |
|
| 192 |
:: |
| 193 |
|
| 194 |
Userlogout => logout_sso |
| 195 |
|
| 196 |
You can create these two headers to fill user name and mail (see |
| 197 |
extension configuration): |
| 198 |
|
| 199 |
:: |
| 200 |
|
| 201 |
Auth-Cn => $cn |
| 202 |
Auth-Mail => $mail |
| 203 |
|
| 204 |
If using LL::NG as reverse proxy, configure also the ``Auth-User`` |
| 205 |
:ref:`header<headers>`, |
| 206 |
|
| 207 |
.. |image0| image:: /applications/mediawiki_logo.png |
| 208 |
:class: align-center |
| 209 |
|