]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/LocalSettings.php.erb
tile: Allow X-Requested-With header via CORS
[chef.git] / cookbooks / mediawiki / templates / default / LocalSettings.php.erb
1 <?php
2 # DO NOT EDIT - This file is being maintained by Chef
3
4 # Protect against web entry
5 if ( !defined( 'MEDIAWIKI' ) ) {
6         exit;
7 }
8
9 ## Uncomment this to disable output compression
10 # $wgDisableOutputCompression = true;
11
12 $wgSitename      = '<%= @mediawiki[:sitename] %>';
13 $wgMetaNamespace = '<%= @mediawiki[:metanamespace] %>';
14
15 ## The URL base path to the directory containing the wiki;
16 ## defaults for all runtime URL paths are based off of this.
17 ## For more information on customizing the URLs
18 ## (like /w/index.php/Page_title to /wiki/Page_title) please see:
19 ## https://www.mediawiki.org/wiki/Manual:Short_URL
20 $wgScriptPath       = "/w";
21 $wgArticlePath      = '/wiki/$1';
22 $wgUsePathInfo      = true;
23 $wgScriptExtension  = ".php";
24
25 ## The protocol and server name to use in fully-qualified URLs
26 $wgServer           = "//<%= @name %>";
27 $wgInternalServer   = 'https://<%= @name %>';
28 $wgCanonicalServer  = 'https://<%= @name %>';
29
30 $wgSecureLogin = true;
31 $wgDefaultUserOptions['prefershttps'] = 1;
32 $wgCookieSecure = true;
33
34 ## The relative URL path to the skins directory
35 $wgStylePath        = "$wgScriptPath/skins";
36
37 ## The relative URL path to the logo.  Make sure you change this from the default,
38 ## or else you'll overwrite your logo when you upgrade!
39 $wgLogo             = "<%= @mediawiki[:logo] %>";
40 $wgLogos            = [
41   "icon" => "<%= @mediawiki[:logo] %>"
42 ];
43
44 ## UPO means: this is also a user preference option
45
46 $wgEnableEmail      = true;
47 $wgEnableUserEmail  = true; # UPO
48
49 $wgEmergencyContact = "<%= @mediawiki[:email_contact] %>";
50 $wgPasswordSender   = "<%= @mediawiki[:email_sender] %>";
51 $wgPasswordSenderName = "<%= @mediawiki[:email_sender_name] %>"; //Replaced by MediaWiki:Emailsender in v1.23.0
52 $wgNoReplyAddress = "<%= @mediawiki[:email_sender] %>";
53
54 $wgEnotifUserTalk      = true; # UPO
55 $wgEnotifWatchlist     = true; # UPO
56 $wgEmailAuthentication = true;
57
58 $wgEnotifUseJobQ       = true;
59
60 $wgSMTP = [
61   "host" => "localhost",
62   "socket_options" => [
63     "ssl" => [
64       "verify_peer_name" => false
65     ]
66   ]
67 ];
68
69 ## Database settings
70 $wgDBtype           = "mysql";
71 $wgDBserver         = "<%= @database_params[:host] %>";
72 $wgDBname           = "<%= @database_params[:name] %>";
73 $wgDBuser           = "<%= @database_params[:username] %>";
74 $wgDBpassword       = "<%= @database_params[:password] %>";
75
76 # MySQL specific settings
77 $wgDBprefix         = "";
78
79 # MySQL table options to use during installation or update
80 $wgDBTableOptions   = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
81
82 # Experimental charset support for MySQL 5.0.
83 $wgDBmysql5 = false;
84
85 ## Shared memory settings
86 $wgMainCacheType    = CACHE_MEMCACHED;
87 $wgParserCacheType  = CACHE_MEMCACHED;
88 $wgMessageCacheType = CACHE_MEMCACHED;
89 $wgSessionCacheType = CACHE_MEMCACHED;
90 $wgMemCachedServers = array('127.0.0.1:11211');
91 $wgSessionsInObjectCache = TRUE;
92
93 ## To enable image uploads, make sure the 'images' directory
94 ## is writable, then set this to true:
95 $wgEnableUploads  = true;
96 $wgUseImageMagick = true;
97 $wgImageMagickConvertCommand = "/usr/bin/convert";
98
99 $wgGenerateThumbnailOnParse = false;
100 $wgMaxImageArea = 125000000;
101 $wgMaxShellMemory = 5524000;
102 $wgMaxShellFileSize = 819200;
103 $wgMaxShellTime = 360;
104 $wgMaxShellWallClockTime = 360;
105
106 # Allow some more upload extensions
107 $wgFileExtensions[] = 'pdf';
108 $wgFileExtensions[] = 'odt';
109 $wgFileExtensions[] = 'odp';
110 $wgFileExtensions[] = 'ods';
111 $wgFileExtensions[] = 'svg';
112 $wgFileExtensions[] = 'osm';
113 $wgFileExtensions[] = 'odg';
114 <% @mediawiki[:extra_file_extensions].each do |mw_extra_file_extension| -%>
115         $wgFileExtensions[] = '<%= mw_extra_file_extension %>';
116 <% end -%>
117
118 # Add OSM XML file format per http://www.iana.org/assignments/media-types/media-types.xhtml
119 # Shout out to Paul Norman for reserving this.
120 # Helps MimeMagic determine XML-based formats and chooses the correct MimeType
121 # for .osm files.
122 $wgXMLMimeTypes[] = array('osm' => 'application/vnd.openstreetmap.data+xml');
123
124 $wgTrustedMediaFormats[] = 'application/vnd.openstreetmap.data+xml';
125
126 $wgSVGConverters = array( 'rsvg' => '/usr/bin/rsvg-convert -w $width -h $height -o $output $input');
127 $wgSVGConverter = 'rsvg';
128 $wgSVGMaxSize = 2000;
129
130 ## If you use ImageMagick (or any other shell command) on a
131 ## Linux server, this will need to be set to the name of an
132 ## available UTF-8 locale
133 $wgShellLocale = "en_US.utf8";
134
135 ## If you want to use image uploads under safe mode,
136 ## create the directories images/archive, images/thumb and
137 ## images/temp, and make them all writable. Then uncomment
138 ## this, if it's not already uncommented:
139 #$wgHashedUploadDirectory = false;
140
141 ## Set $wgCacheDirectory to a writable directory on the web server
142 ## to make your wiki go slightly faster. The directory should not
143 ## be publically accessible from the web.
144 $wgCacheDirectory = "$IP/cache";
145
146 # Site language code, should be one of the list in ./languages/Names.php
147 $wgLanguageCode = "en";
148
149 ## Enable setting the page content language by users
150 $wgPageLanguageUseDB = true;
151 $wgGroupPermissions['user']['pagelang'] = true;
152
153 ## Enable the {{USERLANGUAGE}} magic word
154 $wgParserEnableUserLanguage = true;
155
156 $wgSecretKey = '<%= @secret_key %>';
157
158 # Site upgrade key. Must be set to a string (default provided) to turn on the
159 # web installer while LocalSettings.php is in place
160 #$wgUpgradeKey = "6ad907e74fc65836";
161
162 ## Default skin: you can change the default skin. Use the internal symbolic
163 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
164 $wgDefaultSkin = "<%= @mediawiki[:skin] %>";
165
166 ## For attaching licensing metadata to pages, and displaying an
167 ## appropriate copyright notice / icon. GNU Free Documentation
168 ## License and Creative Commons licenses are supported so far.
169 $wgRightsPage = "Wiki_content_license"; # Set to the title of a wiki page that describes your license/copyright
170 $wgRightsUrl  = "https://creativecommons.org/licenses/by-sa/2.0/";
171 $wgRightsText = "Creative Commons Attribution-ShareAlike 2.0 license";
172 $wgRightsIcon = "/cc-wiki.png";
173
174 # Path to the GNU diff3 utility. Used for conflict resolution.
175 $wgDiff3 = "/usr/bin/diff3";
176
177 $wgExternalDiffEngine = 'wikidiff2';
178
179 # Query string length limit for ResourceLoader. You should only set this if
180 # your web server has a query string length limit (then set it to that limit),
181 # or if you have suhosin.get.max_value_length set in php.ini (then set it to
182 # that value)
183 $wgResourceLoaderMaxQueryLength = -1;
184
185 # End of automatically generated settings.
186 # Add more configuration options below.
187
188 # Only Allow Signed-in users to edit
189 $wgGroupPermissions['*']['edit'] = false;
190
191 # Allow bureaucrat group access to oversight options
192 $wgGroupPermissions['bureaucrat']['hideuser'] = true;
193 $wgGroupPermissions['bureaucrat']['deletelogentry'] = true;
194 $wgGroupPermissions['bureaucrat']['deleterevision'] = true;
195 $wgGroupPermissions['bureaucrat']['suppressrevision'] = true;
196 $wgGroupPermissions['bureaucrat']['suppressionlog'] = true;
197
198 # Since 1.32 MW introduced interface-admin group to separate all UI-related rights. This makes sense for bigger sites,
199 # but for OSM it makes more sense to keep group structure simple.  Give all interface-admin rights to sysops.
200 # Also remove the interface-admin group to avoid confusion.
201 $wgGroupPermissions['sysop'] = array_merge( $wgGroupPermissions['sysop'], $wgGroupPermissions['interface-admin'] );
202 unset( $wgGroupPermissions['interface-admin'] );
203 unset( $wgRevokePermissions['interface-admin'] );
204 unset( $wgAddGroups['interface-admin'] );
205 unset( $wgRemoveGroups['interface-admin'] );
206 unset( $wgGroupsAddToSelf['interface-admin'] );
207 unset( $wgGroupsRemoveFromSelf['interface-admin'] );
208
209 # The v1.32+ gadget system also requires two additional rights
210 # See https://www.mediawiki.org/wiki/Extension:Gadgets
211 $wgGroupPermissions['sysop']['gadgets-edit'] = true;
212 $wgGroupPermissions['sysop']['gadgets-definition-edit'] = true;
213
214 # Create ipblock-exempt group to grant IP block exemption permission
215 $wgGroupPermissions['ipblock-exempt']['ipblock-exempt'] = true;
216
217 <% if @mediawiki[:private_accounts] -%>
218 # Prevent new user registrations except by existing users
219 $wgGroupPermissions['*']['createaccount'] = false;
220 $wgGroupPermissions['user']['createaccount'] = true;
221 <% end -%>
222
223 <% if @mediawiki[:private_site] -%>
224 # Disable reading by anonymous users
225 $wgGroupPermissions['*']['read'] = false;
226
227 # Allow anonymous users to access the login page
228 $wgWhitelistRead = array ("Special:Userlogin");
229
230 # Prevent new user registrations except by sysops
231 $wgGroupPermissions['*']['createaccount'] = false;
232
233 # Restrict access to the upload directory
234 $wgUploadPath = "$wgScriptPath/img_auth.php";
235 <% end -%>
236
237 # Allow Subpages on Main Namespace
238 $wgNamespacesWithSubpages[NS_MAIN] = true;
239
240 # DNS Blacklists to use
241 $wgEnableDnsBlacklist = true;
242 $wgDnsBlacklistUrls = [
243   'http.dnsbl.sorbs.net.',
244   'dnsbl-1.uceprotect.net.'
245 ];
246
247 # Require validated email to edit
248 $wgEmailConfirmToEdit = true;
249
250 # Extend autoblock period
251 $wgAutoblockExpiry = 7776000; // 90 days
252
253 # Disable Hit Counter for Performance
254 $wgDisableCounters = TRUE;
255 # Disable IP in Header to avoid cache issue
256 $wgShowIPinHeader = FALSE;
257
258 # Job Runs by cron
259 $wgJobRunRate = 0;
260
261 # dissolves double redirects automatically
262 $wgFixDoubleRedirects = TRUE;
263
264 # Allow external images from a few sites
265 $wgAllowExternalImagesFrom = [
266   'http://tile.openstreetmap.org/',
267   'https://tile.openstreetmap.org',
268   'http://josm.openstreetmap.de/'
269 ];
270
271 $wgNoFollowDomainExceptions = [
272   'www.openstreetmap.org',
273   'josm.openstreetmap.de',
274   'taginfo.openstreetmap.org',
275   'blog.openstreetmap.org',
276   'forum.openstreetmap.org',
277   'community.openstreetmap.org',
278   'lists.openstreetmap.org',
279   'help.openstreetmap.org',
280   'switch2osm.org',
281   'wiki.osmfoundation.org',
282   'www.openstreetmap.us',
283   'learnosm.org',
284   'nominatim.org',
285   'openstreetmap.community',
286   'www.openstreetbrowser.org',
287   'openinframap.org',
288   'leafletjs.com'
289 ];
290
291 # FIXME - move to specific
292 $wgAllowUserJs = TRUE;
293 $wgAllowUserCss = TRUE;
294
295 # Raise expensive lua (and other function) call limits to match WP
296 # Docs:  https://www.mediawiki.org/wiki/Manual:$wgExpensiveParserFunctionLimit
297 # Wikipedia's Config:  https://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php
298 $wgExpensiveParserFunctionLimit = 500;
299
300
301 <% if @mediawiki[:site_notice] -%>
302 $wgSiteNotice = "<%= @mediawiki[:site_notice] %>";
303 <% end -%>
304 <% if @mediawiki[:site_readonly] -%>
305 $wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : "<%= @mediawiki[:site_readonly] %>";
306 <% end -%>
307
308 <% @mediawiki[:namespaces].each do |name, details| -%>
309 # <%= name %>
310 define('NS_<%= name.upcase %>', <%= details[:id] %>);
311 $wgExtraNamespaces[NS_<%= name.upcase %>] = '<%= name %>';
312 $wgNamespacesWithSubpages[NS_<%= name.upcase %>] = TRUE;
313 $wgContentNamespaces[] = NS_<%= name.upcase %>;
314 $wgNamespacesToBeSearchedDefault[NS_<%= name.upcase %>] = TRUE;
315 define('NS_<%= name.upcase %>_TALK', <%= details[:talk_id] %>);
316 $wgExtraNamespaces[NS_<%= name.upcase %>_TALK] = '<%= name %>_talk';
317 $wgNamespacesWithSubpages[NS_<%= name.upcase %>_TALK] = TRUE;
318
319 <% end -%>
320
321 <% unless @mediawiki[:force_ui_messages].empty? -%>
322 # defines which links of the sidebar are translatable
323 $wgForceUIMsgAsContentMsg = array( '<%= @mediawiki[:force_ui_messages].join("', '") %>' );
324 <% end -%>
325
326 # load extensions
327 <% Dir.glob("#{@directory}/LocalSettings.d/*.php") do |file| -%>
328 <%= "require_once('#{file}');" %>
329 <% end -%>
330
331 <% if @mediawiki[:watch_category_membership] -%>
332 # must be after extensions are loaded
333 $wgRCWatchCategoryMembership = true;
334 <% end -%>
335
336 <% if not(@mediawiki[:private_accounts]) and not(@mediawiki[:private_site]) -%>
337 # require user confirmation for certain actions
338 $wgGroupPermissions['user']['move'] = false;
339 $wgGroupPermissions['user']['movefile'] = false;
340 $wgGroupPermissions['user']['move-categorypages'] = false;
341 $wgGroupPermissions['user']['upload'] = false;
342 $wgGroupPermissions['autoconfirmed']['move'] = true;
343 $wgGroupPermissions['autoconfirmed']['movefile'] = true;
344 $wgGroupPermissions['autoconfirmed']['move-categorypages'] = true;
345 $wgGroupPermissions['autoconfirmed']['upload'] = true;
346 # Autopromote users to autoconfirmed
347 $wgAutoConfirmAge = 345600; // 4 days
348 $wgAutoConfirmCount = 10;
349
350 # user group "confirmed" with identical rights as "autoconfirmed", but assigned manually by sysops
351 $wgGroupPermissions['confirmed'] = $wgGroupPermissions['autoconfirmed'];
352 $wgAddGroups['sysop'][] = 'confirmed';
353 $wgRemoveGroups['sysop'][] = 'confirmed';
354 <% end -%>
355
356 <% if @mediawiki[:private_accounts] or @mediawiki[:private_site] -%>
357 # disable automatic confirmation of users, grant all "autoconfirmed" rights to all users
358 $wgAutoConfirmAge = 0;
359 $wgAutoConfirmCount = 0;
360 $wgGroupPermissions['user'] = array_merge( $wgGroupPermissions['user'], $wgGroupPermissions['autoconfirmed'] );
361
362 unset( $wgGroupPermissions['autoconfirmed'] );
363 unset( $wgRevokePermissions['autoconfirmed'] );
364 unset( $wgAddGroups['autoconfirmed'] );
365 unset( $wgRemoveGroups['autoconfirmed'] );
366 unset( $wgGroupsAddToSelf['autoconfirmed'] );
367 unset( $wgGroupsRemoveFromSelf['autoconfirmed'] );
368 <% end -%>
369
370 # Increase curl timeout to allow parsoid requests to heavy pages like Map Features
371 # Mediawiki 1.38 has fix to allow this to be set by $wgVirtualRestConfig
372 # https://phabricator.wikimedia.org/T285478
373 $wgHTTPTimeout = 240;
374
375 # Enable night mode for Minerva and Vector skins
376 # https://github.com/openstreetmap/operations/issues/1230
377 $wgMinervaNightMode['base'] = true;
378 $wgVectorNightMode['logged_in'] = true;
379 $wgVectorNightMode['logged_out'] = true;
380
381 # Set extremely low timeout to avoid PHP-FPM timeouts on slow connections to Wikimedia Commons (rate limiting) or similar
382 $wgHTTPMaxTimeout = 5;
383 $wgHTTPMaxConnectTimeout = 3;
384
385 # https://github.com/openstreetmap/operations/issues/1357
386 $wgUseRCPatrol = false;
387
388 # Add read-only mode option for maintenance.
389 $wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : false;