Extension talk:Lockdown/Archive 2/Flow export



Does not work on 1.16, over riding permissions

Simply does not work on 1.16 end of debate.

I use the version for 1.15 in 1.16, works fine so far. —The preceding unsigned comment was added by an unknown user on a unknown date. 04:49, 6 June 2011 (UTC)

Extension doesn't work with 1.16.0

The extension doesn't work! If i enable Lockdown, I'm able to edit group membership of every user, while not logged in! I can see every special page, also those, usually only visible to sysops! I'm not using any Lockdown-feature. I only enable it in Localsettings with the line require_once("$IP/extensions/Lockdown/Lockdown.php") and all permissions defined anywhere are deactivated. If Lockdown is enabled, lines like $wgGroupPermissions['*']['edit'] = false; are completely ignored, no matter if the line is placed before or after the Lockdown-line.
Is this normal behaviour? I'm using MediaWiki 1.16.0. The lines in my LocalSettings.php are:

# Lockdown
require_once( "$IP/extensions/Lockdown/Lockdown.php" );
# Force login to edit
$wgGroupPermissions['*']['edit'] = false;

You don't have to use the extension, it's to enough to simply enable it!
Any idea? --82.135.46.2 10:46, 12 January 2011 (UTC) 04:50, 6 June 2011 (UTC)

Update:
Now the extension works after doing this:
  1. Create a restricted namespace
  2. Create an article in that namespace with a user who has permission to do that
  3. Log-out (until now, nothing had changed; I'm still able to access sysop special pages and change user rights as an anonymous)
  4. Search for the article, created in step two
  5. Click on the result (there shouldn't be a result!)
  6. Now you get a restriction failure
  7. From now on, the extension works as expected
The buggy behaviour, described above appeared today's morning out of nowhere. I used the extension for several weeks and saw it today for the first time. Any idea about that? --82.135.46.2 11:57, 12 January 2011 (UTC) 04:50, 6 June 2011 (UTC)
Update:
Now I have figured out the problem: It's something with the cookies. You can reproduce it in the following way:
  1. Log in to your wiki as an admin
  2. Close your browser
  3. Open your browser
  4. Check your cookies: there are two left: wikinameUserID and wikinameUserName
  5. Navigate to your wiki
  6. Go to Special Pages
  7. Here you can see all pages, you could see as an admin, even though you're not logged in!
  8. Deactivate the Lockdown Extension at LocalSettings.php
  9. Reload Special Pages
  10. Now, everything's OK; you're treated as an anonymous, without any rights
  11. Reactivate the Lockdown Extension at LocalSettings.php
  12. Reload Special Pages
  13. Now you're treated as an admin
  14. Delete one of that cookies mentioned above, it doesn't matter which one
  15. Now you're treated as an anonymous
You see: The Lockdown-Extension is the problem.
--82.135.46.2 09:55, 14 January 2011 (UTC) 04:51, 6 June 2011 (UTC)
There was a full thread on this showing how to reproduce exactly the same issue you're seeing but by deleting the PHP session on the server itself... apparently it wasn't migrated over when the discussion was switched from a one-page flat format.
I tried to work extensively to get it brought to someone's attention. Admins here seem more interested in telling users they're wrong and don't know how to use the extension rather than investigating the issue and trying to figure out where it's coming from for some people. RandomUser42 15:29, 10 August 2011 (UTC)
Here's the post from the previous discussion copied over -
Reproduce buggy behavior
Log into the wiki and leave the browser open and wait for your session to expire. (I've read this may be influenced by session.gc_maxlifetime and session.cache_expire in php.ini, but this doesn't seem to be the case for me.) After it expires, you should be able to edit the pages without being logged in.
Update: Here's a much quicker way to make your php session end, and to be able to see the bug. Find where your php sessions are being stored (this is session.save_path in phpinfo(), default /var/lib/php5/ on Ubuntu). Grep the files for your logged in username. Delete the session file for your session. Apache/PHP will recreate it as soon as you navigate to another page on your wiki - however, you should now be logged out AND able to edit pages without logging in. I'm beginning to wonder if this is more of a Mediawiki bug than a bug with this extension 15:35, 10 August 2011 (UTC)

No Problem  :)

Hi. I updated my wiki last week from 1.15.3 to 1.16.1 . I used Lockdown and it continues to work fine. No see this kind of problem and no member reports me anything wrong. Must be a very restricted bug ?? —The preceding unsigned comment was added by an unknown user on a unknown date. 04:51, 6 June 2011 (UTC)

2 Small bugs, Recording user name to history and group name with a space character

Ran into a small bug. Mediawiki 1.16.1 installed. Run Lockdown to restrict pages to the "read only" on a Namespace to all users. Sysop has full permissions to this namespace and I created another group name designated to allow edit, create, and move access on the namespace.

Both are minor.

1st was a user group name, "Namespace editor" and the fact it was not being recognized at all. Yes, I had created the group name and it was in the choices of user rights management page. However, the choice would not hold, nor would it record the choice to give a user that group right. Solved it by naming the group... "NamespaceEditor" as one word no space and it took just fine.

2nd was upon granting the right to an existing user the additional permissions of "NamespaceEditor" there was problem recording to the history of the page upon the edit. It recorded the IP of the user and not his user name. My wiki only allows those with a user account to create, edit, etc. He was already logged in, so it may have been the system recognized he had a new permission, the ability to now edit the Namespace, but was unable to resolve his user name to the history of the page. At first I thought it was a cookie issue, because he stated he was thrown out of log in after he made the edit. However, he made three edits, all on different pages in the Namespace, and it was the 3rd edit upon saving he was thrown out of log in.

He has since logged out, cleared his browser's cache, then logged in again. It is now recording his user name to the Namespace page edits. I am now trying to recreate the bug and will advise if I can. Any one else run into this? Hutchy68 04:52, 6 June 2011 (UTC)

Hutchy68, was your user still able to edit (and have his IP show up in the history) after having been logged out? That's the issue quite a few of us are seeing in 1.16. --134.161.2.55 14:20, 25 January 2011 (UTC) 04:52, 6 June 2011 (UTC)

Why is there a "Warning" for 1.16 on the main page?

Shouldn't the warning be modified to read "Possibly broken for 1.16 if client-side caching is enabled and users don't read the instructions"?

It seems like almost all the issues that people are having are client-side caching or RTFM failures.

I use a combination of Lockdown for Action and Special Page lockdowns, and Extension:SimpleSecurity for namespace management. I have found this to be a rock-solid combination for my relatively simple needs since 1.14 and through 1.16.1, including a public-facing CMS as well as completely private extranet sites with multiple (albeit relatively simple) permission needs.

For those with the freedom to hack and patch their source code and the time to configure things (and work out all sorts of possible Javascript, skin, database, and administration issues), Halo Access Control List may be a possible option, but I have yet to be able to get it to work in a way that meets my needs. --Fungiblename 07:42, 31 January 2011 (UTC) 04:53, 6 June 2011 (UTC)

Browser Issue

Hi When I use this extension along with Mediawiki 1.16.1 and these are the options wth which I use the lockdown extension

  • $wgActionLockdown['history'] = array('user');
  • $wgActionLockdown['edit'] = array('user');
  • $wgNamespacePermissionLockdown[SF_NS_FORM]['read'] = array('user');
  • $wgSpecialPageLockdown['CreateForm'] = array('user');
  • $wgSpecialPageLockdown['AllPages'] = array('user');
  • $wgSpecialPageLockdown['ListUsers'] = array('user');
  • $wgSpecialPageLockdown['BlockList'] = array('user');
  • $wgSpecialPageLockdown['Log'] = array('user');
  • $wgSpecialPageLockdown['RecentChanges'] = array('user');
  • $wgSpecialPageLockdown['Version'] = array('user');
  • $wgSpecialPageLockdown['CreateCategory'] = array('user');
  • $wgSpecialPageLockdown['CreateProperty'] = array('user');
  • $wgSpecialPageLockdown['CreateTemplate'] = array('user');
  • $wgSpecialPageLockdown['Ask'] = array('user');
  • $wgSpecialPageLockdown['FormStart'] = array('user');
  • $wgSpecialPageLockdown['FormStart'] = array('user');

These seem to be working perfectly as expected with Firefox browser(3.6.15) but when I use crome(9.0.597.94) none of the things seem to work.Can you please help me? —The preceding unsigned comment was added by an unknown user on a unknown date. 04:54, 6 June 2011 (UTC)

Security Flaw

If a user creates a redirect to a protected page while using the Vector skin, the user can access that page regardless of whether they have read access or not. Ecliptica 21:32, 6 April 2011 (UTC) 04:54, 6 June 2011 (UTC)

This also applies to inclusion {{:Page}} of redirects #REDIRECT:[[Protected:Page]]. TiCPU 13:30, 3 August 2011 (UTC) 13:30, 3 August 2011 (UTC)
For myself I fixed it using:
diff -udpr includes//parser/Parser.php /root/mediawiki/mediawiki-1.16.4/includes/parser/Parser.php
--- includes//parser/Parser.php	2011-08-03 09:43:32.000000000 -0400
+++ /root/mediawiki/mediawiki-1.16.4/includes/parser/Parser.php	2010-05-11 22:12:12.000000000 -0400
@@ -3154,7 +3154,7 @@ class Parser
 		$deps = array();
 
 		// Loop to fetch the article, with up to 1 redirect
-		for ( $i = 0; $i < 1 && is_object( $title ); $i++ ) {
+		for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) {
 			# Give extensions a chance to select the revision instead
 			$id = false; // Assume current
 			wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( $parser, &$title, &$skip, &$id ) );
Almost the same as removing the loop, Mediawiki won't fetch redirect in inclusion now. TiCPU 13:49, 3 August 2011 (UTC)
My configuration is MW 1.17 with LdapAuthentication 1.2d.
I have restricted access to a page by moving it in a NS_protected namespace.
My lockdown configuration is : $wgNamespacePermissionLockdown[NS_protected]['read'] = array('mygroup');
This work fine but not with page inclusion {{:NS_protected:Page}} or redirection #REDIRECT:[[NS_protected:Page]].
I have tried to patch Parser.php like TiCPU but still have the problem. Klausla 09:17, 8 September 2011 (UTC)

Problems with MediaWiki 1.16.5

I've installed a new MediaWiki sing 1.16.5, where anonymous users do not have the right to edit pages. When I enabled the Lockdown extension, without any further Lockdown config, the edit tab is removed for all logged in users.

Tracing the code the lockdownUserCan() is only called for the read action for logged in users and no further and then lockdownSearchableNamespaces() is called twice when loading a page. Disabling the lockdownSearchableNamespaces() hook makes the problem go away so I investigated further down this way. It turns out that changing

$ugroups = $wgUser->getEffectiveGroups();

inside lockdownSearchableNamespaces to

$ugroups = $wgUser->getEffectiveGroups(true);

fixes this (this disables the cache for getEffectiveGroups()).

With this change my MediaWiki installation works and now lockdownUserCan() is called in addition for edit and move actions when loading a page (after the two calls to lockdownSearchableNamespaces()).

I'm very new to MediaWiki, let alone the MediaWiki APIs, so I'm not sure if this is the correct fix or not or what is actually going on.

For reference the relevant permission related parts of LocalSettings.php are:

$wgGroupPermissions['*']['createaccount']    = false;
$wgGroupPermissions['*']['edit']             = false;
$wgGroupPermissions['*']['createpage']       = false; # 'createpage' requires the 'edit' right
$wgGroupPermissions['*']['createtalk']       = false; # 'createtalk' requires the 'edit' right
$wgGroupPermissions['*']['writeapi']         = false;

# despite documented defaults administrators do not have 'suppressredirect' by default
$wgGroupPermissions['sysop']['suppressredirect'] = true;

require_once( "$IP/extensions/Lockdown/Lockdown.php" ); 212.147.27.179 14:01, 12 May 2011 (UTC) 04:55, 6 June 2011 (UTC)
This has already been fixed if you download the latest snapshot (the "trunk" version) of Lockdown. --Skizzerz 23:19, 12 May 2011 (UTC) 04:55, 6 June 2011 (UTC)
Nice! Great to see it fixed in a proper way ;-) Any chance the fix is propagated to the MW-1.16 snapshot? --212.147.27.179 09:49, 13 May 2011 (UTC) 04:55, 6 June 2011 (UTC)
Hi. Be careful here: if you install the "trunk" version of Lockdown you will need the "trunk" version of MediaWiki too!
I just tried it an got this error:
"Call to undefined method MediaWiki::getAction()"
Better to only correct these getEffectiveGroups() and wait next release of Lockdown, I think. 180.183.208.155 09:51, 14 June 2011 (UTC)
Since no one replied to my posting about 1.17 issues above, I decided to just try upgrading from 16.0 to 16.5 for the security fixes...this is the result.
Warning: Cannot modify header information - headers already sent by (output started
at ..../w/extensions/Lockdown/Lockdown.php:1) in ..../w/includes/WebResponse.php on line 16o
Is this extension being overseen any more? Thanks Hutchy68 13:52, 31 January 2012 (UTC)

Lockdown not showing user groups

I have some strange behavior with lockdown (1.16-r70092) using MW 1.16.5. When I write 'require_once("$IP/extensions/Lockdown/Lockdown.php");' to my LocalSettings.php the Special:Preferences page won't show my user groups anymore (even though they are displayed in the groups List (Special:ListUsers&group=bureaucrat)). I would not mind that, but it also deletes my userrights-permission (i.e. no access to Special:UserRights), so I can't setup the Lockdown Extension properly. Is there any way to work around that? --141.20.192.102 12:02, 3 June 2011 (UTC) 04:56, 6 June 2011 (UTC)

Hi, I also had that problem and I solved it by following the same instructions as below.
I simply changed all getEffectiveGroups() to getEffectiveGroups(true).
Hope this helps, Toniher 14:53, 9 June 2011 (UTC) 14:53, 9 June 2011 (UTC)
It does :) Thank you! 141.20.192.66 10:47, 10 June 2011 (UTC)
The complete patch to apply to the version of Lockdown from 1_17_0 svn-tree:
--- svn-extensions/Lockdown/Lockdown.php        2011-06-27 19:53:38.000000000 +0000
+++ man-extensions/Lockdown-patched/Lockdown.php        2011-06-27 20:26:20.000000000 +0000
@@ -96,7 +96,7 @@
        # print "<br />nsAccessUserCan(".$title->getPrefixedDBkey().", ".$user->getName().", $action)<br />\n";
        # print_r($groups);
 
-       $ugroups = $user->getEffectiveGroups();
+       $ugroups = $user->getEffectiveGroups(true);
        # print_r($ugroups);
 
        $match = array_intersect( $ugroups, $groups );
@@ -127,7 +127,7 @@
        if ( $groups === null ) return true;
        if ( count( $groups ) == 0 ) return false;
 
-       $ugroups = $user->getEffectiveGroups();
+       $ugroups = $user->getEffectiveGroups(true);
        $match = array_intersect( $ugroups, $groups );
 
        if ( $match ) return true;
@@ -136,7 +136,7 @@
 
 function lockdownSearchableNamespaces($arr) {
        global $wgUser, $wgNamespacePermissionLockdown;
-       $ugroups = $wgUser->getEffectiveGroups();
+       $ugroups = $wgUser->getEffectiveGroups(true);
 
        foreach ( $arr as $ns => $name ) {
                $groups = @$wgNamespacePermissionLockdown[$ns]['read'];
@@ -155,7 +155,7 @@
 function lockdownTitle(&$title) {
        if ( is_object($title) ) {
                global $wgUser, $wgNamespacePermissionLockdown;
-               $ugroups = $wgUser->getEffectiveGroups();
+               $ugroups = $wgUser->getEffectiveGroups(true);
 
                $groups = @$wgNamespacePermissionLockdown[$title->getNamespace()]['read'];
                if ( $groups === NULL ) $groups = @$wgNamespacePermissionLockdown['*']['read'];
@@ -184,7 +184,7 @@
                return true;
        }
 
-       $ugroups = $wgUser->getEffectiveGroups();
+       $ugroups = $wgUser->getEffectiveGroups(true);
 
        foreach ( $searchEngine->namespaces as $key => $ns ) {
                $groups = @$wgNamespacePermissionLockdown[$ns]['read'];
91.61.104.241 20:47, 27 June 2011 (UTC)
This patch was added with r94275 Cheers [[kgh]] 21:29, 7 December 2011 (UTC)
Works on 1.17 as well, thanks for your effort 194.213.2.40 15:02, 12 July 2011 (UTC)
It only works correctly with 1.17 in the case you have run the update.php after having replaced the corrected lockdown.php. Feechen 21:41, 5 August 2011 (UTC)

Cannot edit protected pages with Bot in LockDown wiki

Hello,

I have noticed that I cannot edit pages with Perl MediaWiki::Bot bots if they are protected ('protect' or 'autoconfirmed' protections). No problem when done using the same bot logged in as user from the browser. The error I get in the script: Error code 3: protectedpage: The ``autoconfirmed right is required to edit this page at myscript.pl line 189. Any idea? Toniher 20:18, 10 July 2011 (UTC)

Apologies, it's also failing with Lockdown disabled. So it must be another thing. Toniher 10:54, 11 July 2011 (UTC)
No, it still fails. Apart from the previous error, it does not get the bot flag: Mybot doesn't have a bot flag; edits will be visible in RecentChanges at /usr/local/share/perl/5.10.1/MediaWiki/Bot.pm line 1928.. No problem when logged from the browser, though. I'll continue researching. Toniher 07:03, 12 July 2011 (UTC)
The problem I comment is with hook SearchableNamespaces, once only this is disabled, bot is loaded with proper permissions. I suspect it must be MediaWiki bug therefore. I filled a bug. Unless you host private content, you can comment line: $wgHooks['SearchableNamespaces'][] = 'lockdownSearchableNamespaces'; to bring robots back to work. Toniher 15:50, 8 August 2011 (UTC)

permission error on Special:UserRights

Hello and exuse my english. Just installed Lockdown on MediaWiki 1.17.0. When entering as a bureaucrat who has 'userrights' privilege by default, there is a permission error on Special:UserRights, which claims i don't have such right to manage user rights. What could be the problem? Begging your pardon again. 81.30.184.63 17:56, 10 August 2011 (UTC)

Hi, I got the same problem myself. Try to apply getEffectiveGroups(true) patch you can see in another thread below. Otherwise, try to add this line:
$wgSpecialPageLockdown['Userrights'] = array('sysop', 'bureaucrat');
Hope this helps! Toniher 10:43, 11 August 2011 (UTC)
After adding the line you advised, it works well. Thank you very much. 94.41.25.51 11:45, 11 August 2011 (UTC)
I had the same issue; adding the $wgSpecialPageLockdown line to LocalSettings.php, together with the getEffectiveGroups() hack described below, also fixed it for me. Dvd3141 06:48, 23 August 2011 (UTC)

possible conflict with ConfirmAccount extension?

Hi again, i using MediaWiki 1.17.0 and have installed both Lockdown and ConfirmAccount extensions. Without ConfirmAccount included in LocalSettings.php, Lockdown works excellent, and vice versa. But if included along, they does a common error, when registered user groups ('user', 'sysop' etc.) have rights as ' * ' group, not more. I have changed getEffectiveGroups() to getEffectiveGroups(true), like it was recommended below, but it didn't help. Can you please help me? 94.41.25.51 15:56, 11 August 2011 (UTC)

Problem with mw 1.17

I have used Lockdown with mw 1.15 and 1.16 with no problems. I upgraded a 1.15 to 1.17 with the correct extension version. Editing is configured to logged in users. Logged in as sysop I could not edit at all. Removing lockdown and leaving all other extensions all was fine. I set up a clean mw 1.17. Just added require Lockdown extension and sysop has no ability to see extra special pages. This is similar to comments below. Adding the patch below allows sysop to see the extra pages - 'User rights management'. However until the line $wgSpecialPageLockdown['Userrights'] = array('sysop', 'bureaucrat'); is added it is still impossible to use that page and set rights it says you do not have the right. Following that it now seems to work as expected. New namespaces can be locked to sysop and project can be locked to sysop.

There really does seem to be a fundamental problem with this extension and mw 1.17. This is a lot to work out for a simple install. Some indication should go in the main Lockdown extension page and hopefully an updated download for mw 1.17 produced. 86.163.48.222 12:08, 26 August 2011 (UTC)

The problem seems quite simple:
  • MediaWiki starts loading the logged in user
  • While loading it tries to get a list of searchable namespaces and calls the SearchableNamespaces-hook
  • Lockdown kicks in and tries to calculate the searchable namespaces, but needs the groups for that
  • Lockdown asks the user-object for the groups
  • The user-object hasn't finished loading and hasn't loaded the groups yet, so it will only give '*' as the users' groups and caches that.
  • Next time Lockdown - or anything at all! - asks for the groups it will get the cached version: '*'
Changing getEffectiveGroups() to getEffectiveGroups(true) tells MediaWiki to ignore the cache (and even repopulate it) and it will be fixed. However, the first time Lockdown asked for the groups it got a wrong answer so that could cause problems.
The solution is a unfortunately a lot less simple. I think the best way will be to let MediaWiki detect it hasn't loaded the groups yet and do that direct. (Or just change the order so the groups will be loaded before even thinking about searchable namespaces.)
Hope this helps. Quis 23:11, 3 September 2011 (UTC)
Here is what I am getting in my upgrade from Mediawiki 1.16 to 1.17.
<pre style="white-space: pre-wrap">Fatal error: Call to undefined method MediaWiki::getAction() in... ...extensions/Lockdown/Lockdown.php on line 130</pre>
Which throws back a 500 error. Any suggestions as I really need to upgrade another wiki using the Lockdown extension, but will not upgrade until I am sure Lockdown is working properly. Thanks Hutchy68 17:34, 24 January 2012 (UTC)
Edit--- Yes I am using version for 1.18 Hutchy68 17:34, 24 January 2012 (UTC)
I've the same issue. Have changed some php but locking of special pages also does not work... 213.197.11.102 11:10, 30 August 2012 (UTC)

whitelisted pages still need login when anonymous users read is set to false:

Hi.

This is my LocalSettings.php http://pastebin.com/Q39JFZX1

All pages listen in $wgWhitelistRead except Main_page and Hovedside(Main_page in norwegian) are then viewed. But the Main_page still needs logging in.

Im really not sure if I fucked something up, or if something is just broken.

The main_page contains links to all the other pages that can be viewed anonymously. So it's kinda vital that one can view it without logging inn. The other pages and the main page itself contains information on how to get access to the wiki, etc.. Also. Not everyone in the organization will/can have edit access to the wiki, but they will need the anonymous read access. JadeSoturi 17:31, 26 October 2011 (UTC)

I was just having this problem. I found out the issue was an underscore. Mediawiki is forgiving between "Main Page" and "Main_Page", but the script requires it be identical so you need to use "Main Page" and not "Main_Page". 128.61.16.249 19:25, 11 July 2012 (UTC)

why can't i get a non-trunk version for my mediawiki 1.17?

i have a mediawiki version 1.17 running but am unable to get a working version from the site. it say's unable to locate the svn-repository. help? 188.62.170.206 19:35, 7 November 2011 (UTC)

Lockdown and problems with common wiki handling

Hi,

when using Lockdown to keep an Namespace being hidden to normal users, we have the following problems:

User rights cannot be accessed, the listed patches on this side works very well for this!

BUT, pages cannot be deleted...wiki returns I don't have the rights, either if i'm sysop or bureaucrat

Additions to LocalSettings.php:

define("NS_ARKAN", 100);
$wgExtraNamespaces[NS_ARKAN] = "Arkan";
$wgGroupPermissions['arkanology']['Arkan_*'] = true;

require_once( "$IP/extensions/Lockdown/Lockdown.php" );

$wgSpecialPageLockdown['Userrights'] = array('sysop', 'bureaucrat');
$wgNamespacePermissionLockdown[NS_ARKAN]['*'] = array('arkanology');

Sebastian 217.246.34.153 12:59, 14 November 2011 (UTC)

I have the same problem. I wnat only sysop to delete. I got round it with
$wgGroupPermissions['*']['delete'] = true;
$wgNamespacePermissionLockdown[NS_MAIN]['delete'] = array( 'sysop' );
Theory being set everyone to delete and then restrict the main namespace back to sysop. You may need to work through the namespaces if you want them restricted. To just bring back delete the first statement may be enough. 86.186.106.141 12:14, 26 November 2011 (UTC)
I have the same problem. I wnat only sysop to delete. I got round it with
$wgGroupPermissions['*']['delete'] = true;
$wgNamespacePermissionLockdown[NS_MAIN]['delete'] = array( 'sysop' );
Theory being set everyone to delete and then restrict the main namespace back to sysop. You may need to work through the namespaces if you want them restricted. To just bring back delete the first statement may be enough. 86.186.106.141 12:14, 26 November 2011 (UTC)

Locking down special pages

I was having problem with locking down certain special pages based on user groups with Lockdown on MW 1.17 and 1.16. Here is a solution that doesn't need Lockdown at all, just enter this in your LocalSettings.php:
function SpecialPageBlock(&$list){
global $wgUser;
if (in_array('sysop', $wgUser->getGroups()) == 0){
foreach(array('Uncategorizedimages','Unusedimages','Withoutinterwiki', 
'Newimages','Listfiles','MIMEsearch','FileDuplicateSearch','Filepath', 
'Booksources','Mostimages','Tags','Disambiguations','BrokenRedirects','Deadendpages',
'DoubleRedirects','Longpages','Ancientpages','Lonelypages','Fewestrevisions','Protectedpages',
'Protectedtitles','Shortpages','Uncategorizedcategories','Uncategorizedpages','Uncategorizedtemplates',
'Unusedcategories','Unusedtemplates','Wantedcategories','Wantedfiles','Wantedpages','Wantedtemplates',
'Allpages','Prefixindex','Categories','Listredirects','Activeusers','Contributions',
'Log','Newpages','Recentchanges','Recentchangeslinked','Listgrouprights','Listusers',
'Popularpages','Statistics','Allmessages','Version','LinkSearch','Random','Randomredirect',
'Mostlinkedcategories','Mostlinkedpages','Mostlinkedtemplates','Mostcategories','Mostrevisions',
'Export','Whatlinkshere'
)as $i){unset($list[$i]);}}
return true;}
$wgHooks['SpecialPage_initList'][]='SpecialPageBlock';
The example above limits access to the pages listed in the array to the 'sysop' group, by removing the pages from the rest of the groups.
The best thing in this solution is that the pages in the array won't even show up on the SpecialPages.
For some reason Random and MostLinkedPages couldn't be disabled this way, any ideas why? TheRebel 10:30, 20 November 2011 (UTC)
Thanks! A much better solution. People don't even know what they're missing. 203.118.164.219 00:16, 25 November 2011 (UTC)
This works perfectly. This should be linked to from restricting access pages. Thanks a bunch. 50.137.193.149 03:45, 23 July 2012 (UTC)
Here is a function which allows you to specify various user groups and also whitelist pages, as opposed to having to list every single page to block.
function SpecialPageBlock(&$list)
{
	global $wgUser;
	   
	$allowedGroups = array(
		'sysop',
	);
	
	$whiteList = array(
		'Userlogin',
		'Userlogout',
		'Search',
		'Preferences',
		'ChangePassword',
	);
	$allowed = false;
	$userGroups = $wgUser->getGroups();	
	foreach($allowedGroups as $group)
	{		
		if (in_array($group, $userGroups))
		{	
			$allowed = true;
			break;
		}		
	}
		
	if (!$allowed)			
	{
		foreach($list as $key => $specialPage)
		{	
			if (!in_array($key, $whiteList))
			{
				unset($list[$key]);
			}
		}
	}
	
	return true;
}
$wgHooks['SpecialPage_initList'][]='SpecialPageBlock';
Frantik (talk) 00:56, 30 March 2018 (UTC)
Thanks a lot for sharing! Much apprechiated! [[kgh]] (talk) 13:50, 3 April 2018 (UTC)
Thanks - i had to add 'ConfirmEmail', 'CreateAccount', to the $whitelist otherwise it is working for me!
Also i got this to work.. so LockDown is not totally useless for me... ;-)
# Lockdown start
wfLoadExtension( 'Lockdown' );
$wgNamespacePermissionLockdown['*']['edit'] = [ 'sysop' ];
      
You can then add special groups and permissions to flesh groups that can 'read' and/or 'edit' namespaces... appears to be working!

AssetDenmark (talk) 08:32, 10 April 2019 (UTC)

Subscribe to RSS (Atom) feed

Is it possible to have a locked-down wiki that still allows me (as an administrator) to subscribe to the Recent Changes feed, to monitor updates? If so, how do I set this up? Dvd3141 03:08, 19 December 2011 (UTC)

Locdown on Special pages as a NS?

Hi I had a huge problem with nameSpaces and thus I an a bit reluctant to experiment. However what I want to do is a general lockdown on all special pages, less those to make a user login, and naturally a special namespace (say NS_Background). (Running 1.8.1)

Perhaps some of you have a suggestion or solution for me to do this?

I tried to lockdown everything, but the Background pages, like below. But I the anonymous user can't read the 'Background:' pages like this... so what did I miss?

$wgGroupPermissions['*' ]['edit']      = false;     
$wgGroupPermissions['*' ]['read']      = false;  
$wgNamespacePermissionLockdown[NS_Background]['read'] = array('*');
$wgNamespacePermissionLockdown[NS_Background]['edit'] = array('sysop');

What I really wanted to do is something like adding this, to the above:

$wgNamespacePermissionLockdown[NS_SPECIAL]['read'] = array('sysop'); ## Actually this may work??
$wgWhitelistRead = array ( < the special pages for search etc. > ); 

Alternately I would wish for at way to do something like this:

$wgWhitelistRead = array ("Background:", "Special:Search")  /  array ("Background:*", .....) 
$wgWhitelistEdit = array ("Discussion")  ## Giving permission to discus any readable page. 

So I guess I could use some kind of "function call" to build that area something like:

$myWhiteListedNameSpaces = getAllNameSpacesAsAnArray("NS_Background") ## or say getAllCategoryPagesAsAnArray("Background") 
$wgWhitelistRead = array ("Getting started", $myWhiteListedNameSpaces ) Asset 07:48, 15 February 2012 (UTC)

The download link is dead. 2001:6F8:1D1A:0:D03E:8EFE:DD5B:92B1 23:12, 2 July 2012 (UTC)

For me the links to the SVN server work correct. Rrosenfeld (talk) 08:49, 9 July 2012 (UTC)

Lockdown preventing users resetting their password

Hi.

If I have lockdown enabled then users are unable to reset their password or change their password if they have forgotten. They go through the process, but on the final step it says they do not have permission. If have the following defined:

$wgSpecialPageLockdown['ChangePassword'] = array('*');
$wgSpecialPageLockdown['PasswordReset'] = array('user');

But it still does not work. If I disable lockdown then password changes and resets work fine. What required permission am I missing?

Any ideas?

Thanks! Mitchelln (talk) 17:14, 29 November 2012 (UTC)

Works with 1.19.1

Hi all, thought I might just provide a small update. I've tested and implemented the following version details successfully:

MediaWiki 1.19.1 Lockdown-db7023e Quantos (talk) 15:13, 25 January 2013 (UTC)

Update Credits (for Special:Version)

This is picky and definitely not a priority, but it would be nice to be consistent with other extensions (plus, version ID's would be helpful for dependent developers such as myself).

For consistency, credits could be updated:

$wgExtensionCredits['other'][] = array(
	'path' => __FILE__,
	'name' => 'Lockdown',
	'author' => array( 'Daniel Kinzler', 'Platonides'),
	'url' => 'http://mediawiki.org/wiki/Extension:Lockdown',
	'version'  => "1.0",
	'descriptionmsg' => 'lockdown-desc',
);

jdpond (talk) 21:58, 16 March 2013 (UTC)

Making lockdown function

I have lockdown working fine using this:

$wgExtraNamespaces[100] = "Hide";
$wgExtraNamespaces[101] = "Hide_Talk";
$wgGroupPermissions['Hide'] = $wgGroupPermissions['user'];
$wgNamespacePermissionLockdown[100]['*'] = array('Hide');
$wgNamespacePermissionLockdown[101]['*'] = array('Hide');

I have to lockdown a BUNCH of namespaces and there are many admins on the site. So, I had the idea to write this function:

function make_lockdown_space($id, $name)
{
    global $wgExtraNamespaces, $wgGroupPermissions, $wgNamespacePermissionLockdown;
    $wgExtraNamespaces[$id] = $name;
    $wgExtraNamespaces[$id+1] = $name."_Talk";
    $wgGroupPermissions[$name] = $wgGroupPermissions['user'];
    $wgNamespacePermissionLockdown[$id]['*'] = array($name);
    $wgNamespacePermissionLockdown[$id+1]['*'] = array($name);
}

With this function, I theoretically only need:

make_lockdown_space(100, "Hide");

With that function, I check all the arrays. All are set. All look good. However, there is no lockdown. Anyone can see the namespaces that are supposedly locked down. Why? I don't see how it is possible that the arrays are altered without a problem, but lockdown fails. Anyone know what is happening? 71.204.230.66 22:44, 22 March 2013 (UTC)

block edit access to user page - except for admins?

block edit access to user page - except for admins?

$wgNamespacePermissionLockdown[user]['edit'] = array('syop');

Is this the correct coding? Using Mediawiki 1.16

It is not working.

Thank you Igottheconch (talk) 23:55, 5 April 2013 (UTC)

"Not absolutely sure but this seems more correct"
$wgNamespacePermissionLockdown[NS_USER]['edit'] = array('syop');
But yours might work also. Cheers, Mlpearc (powwow) 18:04, 28 July 2013 (UTC)
thank you sir,
I will try this! Igottheconch (talk) 06:00, 30 July 2013 (UTC)

Is it working for mw 1.19 ?

62.219.165.221 11:29, 28 July 2013 (UTC)

Is it working for mw 1.19 ?

Is it working for mw 1.19 ? 62.219.165.221 11:29, 28 July 2013 (UTC)

Locking everything down completely except reading the Main Namespace

I need some help.

I'd like to lockdown the wiki completely and operate as an internal private wiki, but have the main namespace readable by anyone.

That also means locking down access to view file history, special pages, etc..

Is Lockdown the way to do this.. if so how? And are there any security flaws? I know Mediawiki says it's not designed to be a CMS, but if the only thing outside users can do is read the main namespace, then where are the holes?

Thanks, MarkJurgens (talk) 01:53, 17 August 2013 (UTC)

update extension

hi please update this extension to support newer releases of mediawiki please. 86.135.253.19 12:01, 12 January 2014 (UTC)

Could you be more specific about this in case it is not working for MW 1.22? It will be nice to get a more verbose description of the issue which helps the programmers tackle it. Besides, adding the update template to the extensions page only means that the documentation should be updated. It is not read as a Call for Updating the extension itself. Cheers [[kgh]] (talk) 13:13, 12 January 2014 (UTC)

Not working in Mediawiki 1.21

Hello !

Your extension seems just perfect, but I can not make it work for Mediawiki 1.21. Am I missing something ? And I can not find previous versions of the extension.

I have set everything right but I can not manage to lock down rights (even following your exemples).

Thanks for your help ! 78.220.29.24 14:20, 21 January 2014 (UTC)

Working in MediaWiki 1.23wmf11

The trick it seems to get this extension to work is to ensure that your "$wgNamespacePermissionLockdown" config is beneath the 'require_once'.

Example:

#Enable Lockdown
require_once __DIR__ . "/extensions/Lockdown/Lockdown.php";
$wgNamespacePermissionLockdown[NS_TOPSCRT]['edit'] = array('FBI_Agents');
$wgNamespacePermissionLockdown[NS_TOPSCRT]['read'] = array('FBI_Agents');

Ckoerner (talk) 21:57, 6 February 2014 (UTC)

Yeah, the extension has to be invoked prior to using parameters defined by it. As far as I can see the installation and configuration instructions already say to do so but it might use a more explicit wording. I will now change it a bit. Cheers [[kgh]] (talk) 22:42, 6 February 2014 (UTC)
I have just submitted a patch to gerrit that changes this behaviour, so that you can also set the config variables before loading the extension. I think this may be simpler than changing the docs. Olenz (talk) 07:28, 7 February 2014 (UTC)
Well, this is one option too though the comments on the patchset are not in favour. Predominantly extension specific changes are made after the invokation. This also has the advantage that you quickly find the related settings in the "LocalSettings.php" file which is not the worst of ideas for inexperienced wikiadmins. [[kgh]] (talk) 15:44, 7 February 2014 (UTC)

Lockdown and VisualEditor - can't edit protected pages

I have a wiki running 1.23wmf11 and the latest build of VisualEditor, the WYSIWYG editor from Wikimedia. It uses a node.js-based parser to round-trip wikitext called Parsoid.
I have defined a few custom name spaces and enabled VisualEdtior for those name spaces. Everything is working as intended.
If I use $wgNamespacePermissionLockdown to define read and edit rights for user groups VisualEditor does not work.
Instead I'm prompted with a "Error loading data from server: parsoidserver-http-bad-status: 500."
Editing the page with WikiEditor works as intended.
node spits out the following when the attempt to edit is made.
starting parsing of localhost:DBC:Cache_Shadowing_Stop/Start_Suspend/Resume
ERROR in localhost:DBC:Cache_Shadowing_Stop/Start_Suspend/Resume with oldid: 123915
Stack trace: Error: API response is missing query for: DBC:Cache_Shadowing_Stop/Start_Suspend/Resume
at TemplateRequest._handleJSON (/var/www/Parsoid/lib/mediawiki.ApiRequest.js:270:11)
at TemplateRequest.ApiRequest._handleBody (/var/www/Parsoid/lib/mediawiki.ApiRequest.js:192:7)
at TemplateRequest.ApiRequest._requestCB (/var/www/Parsoid/lib/mediawiki.ApiRequest.js:149:8)
at Request.self.callback (/var/www/Parsoid/node_modules/request/request.js:129:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/var/www/Parsoid/node_modules/request/request.js:873:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/var/www/Parsoid/node_modules/request/request.js:824:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
It sounds like the Lockdown extension is somehow getting in the way of Parsoid and the MediaWiki api to make it's calls.
While VisualEditor is not the default editor for MediaWiki, its active development and future roadmap seem to indicate that it will be a preferred way to edit wiki pages for many editors. Any inputs and thoughts would be appreciated. Ckoerner (talk) 19:24, 19 February 2014 (UTC)
Hi, did you ever find a solution for this?
I'm running the Lockdown extension on MediaWiki 1.24.1 with the latest build of VisualEditor and I'm running into the same behavior where I'm unable to edit protected namespaces using VisualEditor.
Any help would be greatly appreciated! 47.19.118.253 19:51, 9 February 2015 (UTC)
I am having the same issue. Pages that are under a namespace which is locked by Lockdown can't be edited with VisualEditor. WikiEditor works
just fine. 89.216.28.24 09:13, 18 March 2015 (UTC)
I have the same problem, but I use HaloACL extension.
Is there any chance to fix this? Monic abc (talk) 09:31, 27 March 2015 (UTC)
https://www.mediawiki.org/wiki/Extension:VisualEditor#Linking_with_Parsoid_in_private_wikis Andrew Garrett (WMF) (talk) 11:27, 18 March 2015 (UTC)
Enabled cookies, still can't get VisualEditor to work on protected pages with Lockdown.
I created a new group called testgroup with a tool AccessControlPanel (frontend to Lockdown) and visited the page testgroup:Main_page in a browser where I was logged in (Firefox) and in another browser (Chrome). In first browser, I saw the edit button to edit the page in VisualEditor and then I got error (js alert dialog) "novenamespace: VisualEditor is not enabled in namespace 138" and after a reload, the VisualEditor Tab button disappeared.
In Chrome the page was restricted and I needed to log in to be able to see it, as expected.
If I manually create a namespace and if I restrict the namespace (read) to a user group in LocalSettings.php, every page created in that namespace can't be edited with VisualEditor. Only with WikiEditor.
Editing any other page that isn't restriced with Lockdown can be edited with VisualEditor. 89.216.28.24 12:52, 18 March 2015 (UTC)
BUMP
I have this identical issue using MW 1.25, parsoid 0.3.0 and the latest drops of Visual Editor and Lockdown.
Did anyone reach a solution for this? 163.244.62.183 (talk) 14:09, 15 July 2015 (UTC)
Hello everyone.
We just have the SAME issue with Visual Editor and Lockdown.
Did anyone find a solution ??
Is this an inevitable problem with lockdown ?
We've been looking for a solution since all the day and nothing's working.
We've trying every solutions posted on the internet and .. no.
Please is there a god on this earth able to help us ??
Thank you Gino3008 (talk) 14:48, 14 January 2016 (UTC)
Hi everybody,
I think the problem is solved in newer Versions of MW and VE, as in my Installation of
MediaWiki 1.27.0-wmf.11 and
VisualEditor 0.1.0 (a6e24f4) 00:37, 1 February 2016
with VisualEditor enabled for the "Project" Namespace, which is write protected by Extension:Lockdown I am able to successfully edit those protected pages with VE. I have a Parsoid-server running on an a private backend-network and I am doing cookie-forwarding.
The Parsoid-server is a git clone from the beginning of February 2016.
Greetings
Hermann HermannSchwärzler (talk) 11:36, 22 February 2016 (UTC)
Hi,
Encouraged by Hermann's example, I tried with latest night (2016.02.24) builts of every bit of software involved but I still get this message :
Erreur lors du chargement des données du serveur : 500: parsoidserver-http: HTTP 500. Voulez-vous réessayer ?
Thanks for any help. Dieudo (talk) 01:00, 25 February 2016 (UTC)
Hi @Dieudo,
this looks like a configuration-error or something. Your parsoid-server had some kind of problem and answered with HTTP code 500 ("Internal Server Error").
How do you start parsoid?
And what do you see it output when you run it with
parsoidConfig.debug = true;
in you localsettings.js?
Greetings
Hermann HermannSchwärzler (talk) 09:51, 25 February 2016 (UTC)
Actually it looks like there's a problem with my lockdown configuration alone. I'll have to check that first. Thx for your help Hermann : ) Dieudo (talk) 22:46, 25 February 2016 (UTC)
The error I get now is :
Fatal error: Call to a member function getId() on a non-object in .../extensions/Lockdown/Lockdown.php on line 163 Dieudo (talk) 09:09, 26 February 2016 (UTC)
Sorry, I forgot to mention that. There seems to be a bug in Lockdown in combination with MW 1.27 - see https://phabricator.wikimedia.org/T127456
Just add this code before line 162:
if ( !$wgUser ) {
return true;
}
HermannSchwärzler (talk) 15:38, 26 February 2016 (UTC)
Thank you Hermann !
This does the trick : )
However, it does it only if when including this line in LocalSettings.php :
$wgGroupPermissions['*']['read'] = false;
I wonder what to do to be able to use both Lockdown and VisualEditor on a wiki not private.
Any idea ? Dieudo (talk) 22:48, 26 February 2016 (UTC)
My solution was, not to load Lockdown, if the request comes from the localhost. In an other configuration I had to take the non-local IP-adress of the server
if ( $_SERVER['REMOTE_ADDR'] != '127.0.0.1' ) {
require_once( "extensions/Lockdown/Lockdown.php" );
}
Additionaly the namespaces had to be activated for VE with $wgVisualEditorAvailableNamespaces
$wgVisualEditorAvailableNamespaces = array(
NS_MAIN     => true,
NS_USER     => true,
NS_HELP     => true,
NS_PROJECT  => true,
NS_MYCUSTOMNAMESPACE  => true,
);
And read and edit permissions had to be given globally if request came from localhost
if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ) {
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = true;
} Textform (talk) 08:26, 3 June 2016 (UTC)
Hi i have the same Problem here.
Where do you put the if Arguments? In the LocalSettings.php? 217.6.132.212 (talk) 15:34, 18 November 2016 (UTC)
Yes, "LocalSetting.php" [[kgh]] (talk) 12:33, 20 November 2016 (UTC)
Hi guys,
I'm dealing with the same issue. If Lockdown is enabled, then VE refuses to save *any* page dispalying message "Permission denied". If I disable Lockdown by commenting out this section:
if ( $_SERVER['REMOTE_ADDR'] != '127.0.0.1' AND $_SERVER['REMOTE_ADDR'] != '::1' ) {
require_once "extensions/Lockdown/Lockdown.php";
}
Then VE works as hell.
I'm using the latest stable mediawiki, parsoid, Lockdown and VE.
My LocalSettings includes also:
$wgVisualEditorAvailableNamespaces = array(
NS_MAIN     => true,
NS_USER     => true,
NS_HELP     => true,
NS_PROJECT  => true,
NS_RESTRICTED => true
);
if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' OR $_SERVER['REMOTE_ADDR'] == '::1' ) {
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = true;
} else {
# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
}
Do you have any idea how this issue can be fixed?
Thanks in advance.
Maciej 109.199.10.165 (talk) 14:15, 29 November 2016 (UTC)
Mediawiki: v1.32.1
NodeJS: v10.15.3
Distribution: Debian GNU/Linux 9.8 (stretch)
Parsoid + VisualEditor + Lockdown (with SSL):
1) sudo apt install xs-utils
2) sudo wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz -O /usr/local/src/nodejs-10.15.3.tar.xz
3) sudo tar xf /usr/local/src/nodejs-10.15.3.tar.xz -C /usr/local/ --stript-components 1
4) sudo npm install -g parsoid
5) sudo vim /usr/local/lib/node_modules/parsoid/config.yaml
=====------ START config.yaml -------=====
services:
  - module: lib/index.js
    entrypoint: apiServiceWorker
    conf:
        mwApis:
        - uri: 'http://{{ fqdn }}/{{ mw_wiki_dir_name }}/api.php'
        # - uri: 'https://{{ fqdn }}/{{ mw_wiki_dir_name }}/api.php' # If you redirect all HTTP traffic to HTTPS
        # - uri: 'http://{{ other_fqdn }}/{{ mw_wiki_dir_name }}/api.php'
------ END config.yaml -------
6) sudo vim /etc/systemd/system/parsoid.service
----- START parsoid.service -----
[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/local/lib/node_modules/parsoid
ExecStart=/usr/local/bin/node /usr/local/lib/node_modules/parsoid/bin/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
----- END parsoid.service -----
7) sudo service parsoid start (this load parsoid on port 8000)
8) sudo systemctl enable parsoid
9) sudo apt install stunnel
10) sudo vim /etc/stunnel/parsoid.conf
----- START parsoid.conf -----
cert = /etc/ssl/certs/{{ fqdn }}.crt
key = /etc/ssl/private/{{ fqdn }}.key
CAfile = /etc/ssl/certs/ca-certificates.crt
[parsoid]
accept  = 8143
connect = 8000
----- END parsoid.conf -----
11) sudo vim /etc/default/stunnel4
----- START stunnel4 -----
...
# Change to one to enable stunnel automatic startup
ENABLED=1
...
----- END stunnel4 -----
12) sudo service stunnel4 restart (now you can reach parsoid on 8143)
13) sudo vim .../w/LocalSettings.php
----- START LocalSettings.php -----
...
// NEW Namespaces
define("NS_NEW_1", 3000);
define("NS_NEW_1_TALK", 3001);
$wgExtraNamespaces[NS_NEW_1]                  = "NEW1";
$wgExtraNamespaces[NS_NEW_1_TALK]       = "NEW1_talk";          # Note underscores in the namespace name.
$wgNamespaceProtection[NS_NEW_1]            = array( 'edit-new1' );      # "edit-new1" required to edit NEW1:pages
$wgNamespaceProtection[NS_NEW_1_TALK] = array( 'edit-new1-talk' ); # "edit-new1-talk" required to edit NEW1_talk:pages
$wgNamespacesWithSubpages[NS_NEW_1]  = true;        # subpages enabled for the NEW1 namespace
$wgGroupPermissions['new1']['edit-new1']           = true;     # permission "edit-new1" granted to users in the "new1" group
$wgGroupPermissions['new1']['edit-new1-talk']    = true;     # permission "edit-new1-talk" granted to users in the "new1" group
$wgContentNamespaces[]                            = NS_NEW_1; #prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[]                 = NS_NEW_1;
$wgNonincludableNamespaces[]                 = NS_NEW_1_TALK;
wfLoadExtension( 'Lockdown' );
#restrict all permissions on pages with namespace "NEW" to users belonging to 'new1' group
$wgNamespacePermissionLockdown[NS_NEW_1]['*'] = array('new1');
$wgNamespacePermissionLockdown[NS_NEW_1_TALK]['*'] = array('new1');
wfLoadExtension( 'VisualEditor' );
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    'url' => 'https://{{ fqdn }}:8143',
    'forwardCookies' => true,
);
$wgVisualEditorAvailableNamespaces = [
    NS_MAIN => true,
    NS_USER => true,
    NS_HELP => true,
    NS_NEW_1 => true,
];
...
----- END LocalSettings.php -----
Parsoid + VisualEditor (without SSL):
1) sudo apt install xs-utils
2) sudo wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz -O /usr/local/src/nodejs-10.15.3.tar.xz
3) sudo tar xf /usr/local/src/nodejs-10.15.3.tar.xz -C /usr/local/ --stript-components 1
4) sudo npm install -g parsoid
5) sudo vim /usr/local/lib/node_modules/parsoid/config.yaml
=====------ START config.yaml -------=====
services:
  - module: lib/index.js
    entrypoint: apiServiceWorker
    conf:
        mwApis:
        - uri: 'http://{{ fqdn }}/{{ mw_wiki_dir_name }}/api.php'
        # - uri: 'https://{{ fqdn }}/{{ mw_wiki_dir_name }}/api.php' # If you redirect all HTTP traffic to HTTPS
        # - uri: 'http://{{ other_fqdn }}/{{ mw_wiki_dir_name }}/api.php'
------ END config.yaml -------
6) sudo vim /etc/systemd/system/parsoid.service
----- START parsoid.service -----
[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/local/lib/node_modules/parsoid
ExecStart=/usr/local/bin/node /usr/local/lib/node_modules/parsoid/bin/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
----- END parsoid.service -----
7) sudo service parsoid start (this load parsoid on port 8000)
8) sudo systemctl enable parsoid
9) sudo apt install stunnel
10) sudo vim .../w/LocalSettings.php
----- START LocalSettings.php -----
...
// NEW Namespaces
define("NS_NEW_1", 3000);
define("NS_NEW_1_TALK", 3001);
$wgExtraNamespaces[NS_NEW_1]                  = "NEW1";
$wgExtraNamespaces[NS_NEW_1_TALK]       = "NEW1_talk";          # Note underscores in the namespace name.
$wgNamespaceProtection[NS_NEW_1]            = array( 'edit-new1' );      # "edit-new1" required to edit NEW1:pages
$wgNamespaceProtection[NS_NEW_1_TALK] = array( 'edit-new1-talk' ); # "edit-new1-talk" required to edit NEW1_talk:pages
$wgNamespacesWithSubpages[NS_NEW_1]  = true;        # subpages enabled for the NEW1 namespace
$wgGroupPermissions['new1']['edit-new1']           = true;      # permission "edit-new1" granted to users in the "new1" group
$wgGroupPermissions['new1']['edit-new1-talk']    = true;      # permission "edit-new1-talk" granted to users in the "new1" group
$wgContentNamespaces[]                            = NS_NEW_1; #prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[]                 = NS_NEW_1;
$wgNonincludableNamespaces[]                 = NS_NEW_1_TALK;
wfLoadExtension( 'Lockdown' );
#restrict all permissions on pages with namespace "NEW" to users belonging to 'new1' group
$wgNamespacePermissionLockdown[NS_NEW_1]['*'] = array('new1');
$wgNamespacePermissionLockdown[NS_NEW_1_TALK]['*'] = array('new1');
wfLoadExtension( 'VisualEditor' );
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    'url' => 'http://127.0.0.1:8000',
    'forwardCookies' => true,
);
$wgVisualEditorAvailableNamespaces = [
    NS_MAIN => true,
    NS_USER => true,
    NS_HELP => true,
    NS_NEW_1 => true,
]; MaLa (talk) 10:31, 4 April 2019 (UTC)
Maybe related to phab:T260201. Valerio Bozzolan (talk) 13:59, 18 December 2020 (UTC)

Hide Sidebar Menu Items for locked down pages

I've successfully implemented the Lockdown extension to prevent pages from being accessed. However, the links that the user cannot access are still shown in the Sidebar.

Is there a way to remove links from the sidebar? (i.e. can I hide links based on the pages they point to that are part of namespaces that are not able to be accessed by the current logged in user?) 50.32.27.234 15:22, 3 March 2014 (UTC)

Do you mind sharing how you got this to work? 76.68.137.45 06:33, 27 October 2014 (UTC)
Well, this IP did not get it to work. I believe the UserFunctions extension is the best way to display per group links in the sidebar. [[kgh]] (talk) 16:23, 27 October 2014 (UTC)

Restrict createpage-right in Project-Namespace

Hello,
what's the right way to restrict the right to create a page in the Project-namespace (NS_PROJECT) to a certain group, but allow all other to edit them.
I tried this:
$wgGroupPermissions['*']['edit'] = true;
$wgNamespacePermissionLockdown[NS_PROJECT]['createpage'] = array('sysop');
But it wont work. Still every logged in user can create pages in the project namespace. Finswimmer (talk) 15:51, 4 March 2014 (UTC)
Did you ever get this to work? 76.68.137.45 06:33, 27 October 2014 (UTC)
Hmm... , I do not think this can be done since action "edit" includes action "createpage" (some sort of "rights inheritance"). However, I may still be proven wrong. [[kgh]] (talk) 22:49, 27 October 2014 (UTC)
I found a way using the Extension AbuseFilter with the following Filter and the "disallow" action:
(page_namespace = 0) &
(old_wikitext == "") &
!( 'sysop' in user_rights ) &
!contains_any(added_lines, "redirect")
It is certainly not perfect and notifies the user only after hitting "save", but it works. Halungg (talk) 15:31, 8 October 2020 (UTC)
I am trying to do something similar and indeed it does not seem to work. I want only members of a certain group to be able to create pages on the main namespace, but allow everyone else to edit those pages once they exist.
Here is what I tried:
$wgGroupPermissions['user']['createpage'] = true;</code> $wgGroupPermissions['creator']['createpage'] = true; $wgNamespacePermissionLockdown['*']['createpage'] = array('user'); $wgNamespacePermissionLockdown[NS_MAIN]['createpage'] = array('creator');
But it does not work. All users can still create pages on the Main Namespace, even if they are not members of the 'creator' group.
Too bad.... Rbirmann (talk) 15:21, 29 February 2016 (UTC)

Lockdown extension developer needed for grant

See idea at m:Grants:IdeaLab/A place to work together.

  • If you'd like to develop the Lockdown extension, you may get a few thousands dollars to do it.
  • If you use the Lockdown extension, please document in bugzilla reports what's missing for it to satisfy the requirements.

(Also posted on mediawiki-l.) Nemo 09:11, 26 April 2014 (UTC)

Nemo, I've done a bit of work in using lockdown.
See: Extension:NSFileRepo jdpond (talk) 11:49, 26 April 2014 (UTC)
You're free to edit the idea on Meta, add yourself as participant and then (if you wish) bring it up as actual (IEG) grant request, ideally together with some more participants. :) Nemo 09:46, 27 April 2014 (UTC)

This extension is not working for me

  • I'm using mediawiki 1.23 on Fedora
  • I created a namespace called "project".
  • I properly installed the extension (checked Special:Version).
  • I put this in the LocalSettings.php file:

$wgNamespacePermissionLockdown[NS_PROJECT]['*'] = array('sysop');

  • I created a page at project:AA
  • I can still access the page project:AA from a non sysop user.

It appears that this extension is no longer functional. Any ideas? 76.68.137.45 06:31, 27 October 2014 (UTC)

The extension works for me.
About the project namespace, see $wgMetaNamespace. Shirayuki (talk) 07:14, 27 October 2014 (UTC)
I figured out why it wasn't working. I just realised that once I put a page in the $wgWhitelistRead array then I can't disable read access to that page through this extension. Mfort123 (talk) 17:38, 27 October 2014 (UTC)

lockdown for Special namespace

It is possible to lockdown the special namespace? I do not want users having access to the Special namespace, so I wrote this in LocalSettings.php:

$wgNamespacePermissionLockdown[NS_SPECIAL]['read'] = array('bureaucrat');

I seem to be able to access special pages through a user that is not in group bureaucrat. Mfort123 (talk) 03:47, 28 October 2014 (UTC)

It does not make sense to do this. Logging into or out of a wiki already requires access to special pages. I suggest to lock down only selected special pages. [[kgh]] (talk) 09:22, 28 October 2014 (UTC)
My plan was to put the login,logout and other specific special pages in the $wgWhitelistRead array and then block the Special namespace. Then all the special pages would be blocked to users except a few of them (like login and logout). This approach doesn't seem to work.
I've never studied the php language, but I was able to look at the Lockdown.php file and make sense of it. For my needs, I ended up commenting out the part where pages specified in the $wgWhitelistRead array cannot be denied read acces. Mfort123 (talk) 18:10, 28 October 2014 (UTC)

On using the $wgSpecialPageLockdown

I don't think it was mentioned in the README file, but one should be careful about specifying the page name when using $wgSpecialPageLockdown. Say I want to block read access to Special:UncategorizedCategories, then I would naturally do something like this:

$wgSpecialPageLockdown['UncategorizedCategories'] = array('bureaucrat');

This is incorrect. You need to replace 'UncategorizedCategories' with 'Uncategorizedcategories'.

This is true for every special page with a title being the concatenation of two or more words such as 'UncategorizedCategories' above. Mfort123 (talk) 18:19, 28 October 2014 (UTC)

How to prevent access to Login/signup page?

As in the question - how to prevent access to Special:Login/signup page? Is it the same as createaccount page? Because if yes then

  $wgGroupPermissions['*']['createaccount'] = false;

doesn't work for me. Monic abc (talk) 14:51, 9 January 2015 (UTC)

Are you sure you placed this line in the correct position of your LocalSettings.php? Nemo 17:40, 9 January 2015 (UTC)
What does it mean "correct position" for you? Because I don't get it. Monic abc (talk) 12:47, 12 January 2015 (UTC)
If you include ConfirmAccount as very last thing in your LocalSettings.php, there should be no need of
$wgGroupPermissions['*']['createaccount'] = false;
because ConfirmAccount sets this on its own. If you have other extensions or core configuration settings after ConfirmAccount, then they might be overriding this setting. Nemo 17:33, 14 January 2015 (UTC)
Ok, I found out that this problem is connected with HaloACL extension. When I comment out lines with it, there is no link to Login/signup page. Monic abc (talk) 13:01, 3 February 2015 (UTC)

Lockdown does not seem to work for users not logged in

I setup a namespace

define("NS_project", 1006);
define("NS_project_TALK", 1007);

$wgExtraNamespaces[NS_project] = "project";
$wgExtraNamespaces[NS_project_TALK] = "project_talk";   // underscore required


require_once "$IP/extensions/Lockdown/Lockdown.php";
$wgNamespacePermissionLockdown[NS_project]['*'] = array('sysop');
$wgNamespacePermissionLockdown[NS_project_TALK]['*'] = array('sysop');
$wgNonincludableNamespaces[] = NS_project;
$wgNonincludableNamespaces[] = NS_project_talk;

I can read pages in this namespace if I'm not logged in. Can I prevent this? Legaulph (talk) 14:08, 12 January 2015 (UTC)

Have you tried unsetting the "read" right from "*" (all users) and then whitelisting it for the users you want to have read rights? Nemo 15:11, 22 January 2015 (UTC)

i want to non-login user can't view my special page

i want (non login user) can't view my special page


what should i do?

my english level is not good at :) but i want to know

thank you 210.126.48.175 05:57, 3 February 2015 (UTC)

Which special pages are you want to make inaccessible to anonymous users? *devunt (talk) 06:32, 3 February 2015 (UTC)
um... i want Special:ListFiles
what should i do? 211.108.29.181 15:19, 3 February 2015 (UTC)

How to prevent api access locked page?

Sofar user can't access page from wiki interface but some of them find out that by using action=parse in api is able to bypass "lockdown".

How to prevent api access locked page? Zoglun (talk) 06:12, 28 February 2015 (UTC)

Something drastic like this should work, if you're not using that API for anything: gerrit:193563. Nemo 09:49, 28 February 2015 (UTC)

Recent changes lockdown patch

I have created a custom namespace using lockdown, and would like to hide that namespace in recent changes, I've tried these patches but can not get them to work, I'm not sure if it's the patch or something else. Anyone familiar with this process that can shed some light would be greatly appreciated, thanx Mlpearc (open channel) 16:49, 28 March 2015 (UTC)

Strange behavior with MW1.27

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


I recently updated MW to the latest commits (it was 1.27 from late 2015). Since than Lockdown is causing very strage permission behavior, apparently it does not recognize the different between logged users and anonymous users (i.e - logged-on sysop cannot edit MW namespace pages, logged users cannot edit etc. 5.29.75.205 (talk) 11:00, 19 May 2016 (UTC)

Facing the same situation. Maybe there's a change in recent commits regarding user permissions? Wess (talk) 19:03, 21 May 2016 (UTC)
I suspect that this is what I described in T137051. To sum up: Lockdown is not compatible with MW 1.27 yet. [[kgh]] (talk) 22:11, 9 June 2016 (UTC)
Did the fix Lockdown: 0d59ae7a7e0e3eb5a4638ba8f814a57926dada42 work? Aloist (talk) 16:34, 3 July 2016 (UTC)
No, unfortunately not. [[kgh]] (talk) 16:36, 3 July 2016 (UTC)
Is somebody going to fix it?
At the moment, when I want to mange user rights, I had to disable the Lockdown extension.
I need it however to protect some namespaces from public access, Aloist (talk) 17:12, 6 July 2016 (UTC)
Hopefully. I am not a coder so I cannot do it. Keeping fingers crossed. [[kgh]] (talk) 18:53, 6 July 2016 (UTC)
I think I have a fix.
Using the version from git master, file Lockdown.php dated 31-may-2016, I replaced
in function function lockdownSearchableNamespaces($arr) {
the line
//if ( $user->getId() === null && $user->getName() === null ) {
with
if ( $user->getId() === null || $user->getName() === null || $user->getName() == '' ) {
I do not claim to understand it, but it resolves the problem that the extension locks out users from editing, who normally have the permission to edit. Aloist (talk) 12:02, 9 July 2016 (UTC)
im still seeing the problem that i cant add or edit permissions for users as a sysop, even after applying the change above :/ 108.171.128.176 (talk) 16:09, 25 July 2016 (UTC)
I have uploaded a patch set suggested by a user which at least restores functionality: gerrit. I dunno if it gets through though. The current status on this issue is however always visible on phabricator. [[kgh]] (talk) 13:44, 2 August 2016 (UTC)
REL1_27 has now been fixed with a patch from Javawookie. Thanks a lot. [[kgh]] (talk) 13:58, 17 August 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Still not working in MW 1.27 for regular users

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Cloned it, downloaded it, etc., but still not working. AS far as I can tell I have the newest version. Any help would be great @Kghbln Christharp (talk) 00:42, 26 August 2016 (UTC)

Works for me. Are you sure that you are on REL1_27 of this extension? Indeed, master will not work. [[kgh]] (talk) 15:51, 26 August 2016 (UTC)
Tried and tried. Nothing seems to work. Tried downloading, tried git clone, etc., tried the REL1_27 and the master. It never works. So not sure what is going on if it's working for other people. Christharp (talk) 18:39, 26 August 2016 (UTC)
This is a bit confusing. You could try to manually apply the change. Apart from that: What exactly is not working for you? [[kgh]] (talk) 08:32, 29 August 2016 (UTC)
I tried master too at first (which didn't work). Then I used the Extension Distributor, which gave me the working version :) Stefahn (talk) 13:17, 29 August 2016 (UTC)
I tried to use Lockdown within private wiki (i.e. $wgGroupPermissions['*']['read'] = false).
It breaks WikiEditor preview feature. I found that even being sysop I don't have read right for API. Digging further showed that 'user' (and 'autoconfirmed') implicit groups were not added to my user (thus leaving only explicit ones and '*'), while basic permissions such as read/write are in 'user' group. I am not that good with MW code to figure out the reason, but it appears that Lockdown calls User::GetRights() too early which results in memoizing only '*' group in mEffectiveGroups.
The version cloned from the git master would not allow me read rights at all, so I cannot access my wiki even as sysop. 176.195.65.39 (talk) 21:23, 17 September 2016 (UTC)
I just tested with WikiEditor and I cannot confirm your observation. I think the issue is that you did not upgrade your version of Lockdown in the first case and later on you just upgraded to master which will fail too as expected. Move in the version for MediaWiki 1.27 i. e. REL1_27 since this is actually the only working version for MW 1.27.x. [[kgh]] (talk) 07:58, 18 September 2016 (UTC)
You are right, I reinstalled REL1_27 anew and the problem resolved. 79.104.211.130 (talk) 14:01, 20 September 2016 (UTC)
Great, thanks for confirming. [[kgh]] (talk) 14:14, 20 September 2016 (UTC)
I should apologize because the only reason my problem appeared resolved after I installed REL1_27 was that I had Lockdown extension commented out in LocalSettings.
So, today I tested it again and preview did not work. Namely, request to /w/api.php with this POST data:
action:parse
format:json
formatversion:2
title:<Title here>
text:<Content here>
pst:
prop:text|modules|jsconfigvars
preview:true
disableeditsection:true
uselang:ru
fails with the following response: {"error":{"code":"readapidenied","info":"You need read permission to use this module","docref":"See http://doc.ifcg.ru/w/api.php for API usage"}}
Non-default part of my LocalSettings follows:
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;
# Enabled Extensions. Most extensions are enabled by including the base extension file here
# but check specific extension documentation for more details
# The following extensions were automatically enabled:
wfLoadExtension( "Cite" );
wfLoadExtension( "Interwiki" );
wfLoadExtension( "SyntaxHighlight_GeSHi" );
wfLoadExtension( "WikiEditor" );
wfLoadExtension( "ParserFunctions" );
require_once( "$IP/extensions/Lockdown/Lockdown.php" );
require_once( "$IP/extensions/Scribunto/Scribunto.php" );
$wgScribuntoDefaultEngine = 'luasandbox';
# File upload
$wgFileExtensions[] = 'docx';
$wgFileExtensions[] = 'doc';
$wgFileExtensions[] = 'xlsx';
$wgFileExtensions[] = 'xls';
$wgFileExtensions[] = 'pptx';
$wgFileExtensions[] = 'ppt';
$wgFileExtensions[] = 'pdf';
$wgFileExtensions[] = 'mpp';
$wgFileExtensions[] = 'odt';
$wgFileExtensions[] = 'ods';
$wgFileExtensions[] = 'odg';
$wgFileExtensions[] = 'odp';
$wgFileExtensions[] = 'djvu';
$wgFileExtensions[] = 'svg';
# Hide Powered icon
$wgFooterIcons = ['copyright' => ['copyright' => false]];
# Hide About/Privacy etc footer links
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'hookFooterLinks';
function hookFooterLinks( $sk, &$tpl ) {
$tpl->data['footerlinks']['places'] = array();
return true;
}
## WikiEditor
# Enables use of WikiEditor by default but still allows users to disable it in preferences
$wgDefaultUserOptions['usebetatoolbar'] = 1;
# Enables link and table wizards by default but still allows users to disable them in preferences
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
# Displays the Preview and Changes tabs
$wgDefaultUserOptions['wikieditor-preview'] = 1;
# Displays the Publish and Cancel buttons on the top right side
$wgDefaultUserOptions['wikieditor-publish'] = 1;
define("NS_RD", 3000);
define("NS_RD_TALK", 3001);
define("NS_TO", 3002);
define("NS_TO_TALK", 3003);
define("NS_CERT", 3004);
define("NS_CERT_TALK", 3005);
$wgExtraNamespaces[NS_RD] = "РД";
$wgExtraNamespaces[NS_RD_TALK] = "РД_Обсуждение";
$wgExtraNamespaces[NS_TO] = "ТО";
$wgExtraNamespaces[NS_TO_TALK] = "ТО_Обсуждение";
$wgExtraNamespaces[NS_CERT] = "С";
$wgExtraNamespaces[NS_CERT_TALK] = "С_Обсуждение";
$wgGroupPermissions['rd']['edit'] = true;
$wgGroupPermissions['to']['edit'] = true;
$wgGroupPermissions['cert']['edit'] = true;
$wgNamespacePermissionLockdown[NS_RD]['edit'] = array('sysop', 'rd');
$wgNamespacePermissionLockdown[NS_TO]['edit'] = array('sysop', 'to');
$wgNamespacePermissionLockdown[NS_CERT]['edit'] = array('sysop', 'cert');
Hope this will help. 79.104.211.130 (talk) 16:20, 22 September 2016 (UTC)
Same problem here.
I use REL-1.27 (0d8aa13) with a private wiki (access only for logged in users).
On API access I get the message "readapidenied".
The problem is, that checkExecutePermissions() in ApiMain.php has $user->isAllowed( 'read' ) unset, which results in the above error.
But I have no idea, what I have to do to get this set here. Rrosenfeld (talk) 13:06, 30 September 2016 (UTC)
To prevent this thread from getting messy all the way I created a separate one called " Not working in MW 1.27 via API" [[kgh]] (talk) 15:26, 4 October 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Not working in MW 1.27 via API

-- Originally posted by 79.104.211.130 --

I should apologize because the only reason my problem appeared resolved after I installed REL1_27 was that I had Lockdown extension commented out in LocalSettings.

So, today I tested it again and preview did not work. Namely, request to /w/api.php with this POST data:

action:parse

format:json

formatversion:2

title:<Title here>

text:<Content here>

pst:

prop:text|modules|jsconfigvars

preview:true

disableeditsection:true

uselang:ru

fails with the following response: {"error":{"code":"readapidenied","info":"You need read permission to use this module","docref":"See http://doc.ifcg.ru/w/api.php for API usage"}}

Non-default part of my LocalSettings follows:

Extended content

$wgGroupPermissions['*']['createaccount'] = false;

$wgGroupPermissions['*']['edit'] = false;

$wgGroupPermissions['*']['read'] = false;

# Enabled Extensions. Most extensions are enabled by including the base extension file here

# but check specific extension documentation for more details

# The following extensions were automatically enabled:

wfLoadExtension( "Cite" );

wfLoadExtension( "Interwiki" );

wfLoadExtension( "SyntaxHighlight_GeSHi" );

wfLoadExtension( "WikiEditor" );

wfLoadExtension( "ParserFunctions" );

require_once( "$IP/extensions/Lockdown/Lockdown.php" );

require_once( "$IP/extensions/Scribunto/Scribunto.php" );

$wgScribuntoDefaultEngine = 'luasandbox';

# File upload

$wgFileExtensions[] = 'docx';

$wgFileExtensions[] = 'doc';

$wgFileExtensions[] = 'xlsx';

$wgFileExtensions[] = 'xls';

$wgFileExtensions[] = 'pptx';

$wgFileExtensions[] = 'ppt';

$wgFileExtensions[] = 'pdf';

$wgFileExtensions[] = 'mpp';

$wgFileExtensions[] = 'odt';

$wgFileExtensions[] = 'ods';

$wgFileExtensions[] = 'odg';

$wgFileExtensions[] = 'odp';

$wgFileExtensions[] = 'djvu';

$wgFileExtensions[] = 'svg';

# Hide Powered icon

$wgFooterIcons = ['copyright' => ['copyright' => false]];

# Hide About/Privacy etc footer links

$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'hookFooterLinks';

function hookFooterLinks( $sk, &$tpl ) {

$tpl->data['footerlinks']['places'] = array();

return true;

}

## WikiEditor

# Enables use of WikiEditor by default but still allows users to disable it in preferences

$wgDefaultUserOptions['usebetatoolbar'] = 1;

# Enables link and table wizards by default but still allows users to disable them in preferences

$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;

# Displays the Preview and Changes tabs

$wgDefaultUserOptions['wikieditor-preview'] = 1;

# Displays the Publish and Cancel buttons on the top right side

$wgDefaultUserOptions['wikieditor-publish'] = 1;

define("NS_RD", 3000);

define("NS_RD_TALK", 3001);

define("NS_TO", 3002);

define("NS_TO_TALK", 3003);

define("NS_CERT", 3004);

define("NS_CERT_TALK", 3005);

$wgExtraNamespaces[NS_RD] = "РД";

$wgExtraNamespaces[NS_RD_TALK] = "РД_Обсуждение";

$wgExtraNamespaces[NS_TO] = "ТО";

$wgExtraNamespaces[NS_TO_TALK] = "ТО_Обсуждение";

$wgExtraNamespaces[NS_CERT] = "С";

$wgExtraNamespaces[NS_CERT_TALK] = "С_Обсуждение";

$wgGroupPermissions['rd']['edit'] = true;

$wgGroupPermissions['to']['edit'] = true;

$wgGroupPermissions['cert']['edit'] = true;

$wgNamespacePermissionLockdown[NS_RD]['edit'] = array('sysop', 'rd');

$wgNamespacePermissionLockdown[NS_TO]['edit'] = array('sysop', 'to');

$wgNamespacePermissionLockdown[NS_CERT]['edit'] = array('sysop', 'cert');

Hope this will help. [[kgh]] (talk) 15:21, 4 October 2016 (UTC)

-- Originally posted by Rrosenfeld --
Same problem here.
I use REL-1.27 (0d8aa13) with a private wiki (access only for logged in users).
On API access I get the message "readapidenied".
The problem is, that checkExecutePermissions() in ApiMain.php has $user->isAllowed( 'read' ) unset, which results in the above error.
But I have no idea, what I have to do to get this set here. [[kgh]] (talk) 15:23, 4 October 2016 (UTC)
Cannot this be overcome by assigning the bot to a usergroup which is allowed to edit? If not an issue report should be created at Phabricator and linked back and forth to this thread. [[kgh]] (talk) 15:29, 4 October 2016 (UTC)
I guess this is now tracked with task T148582. [[kgh]] (talk) 08:09, 24 October 2016 (UTC)
I replaced the ApiParse.php file with the newest code from: https://raw.githubusercontent.com/wikimedia/mediawiki/master/includes/api/ApiParse.php
And it does not work too. Deletedaccount4567435 (talk) 05:38, 26 October 2016 (UTC)
Thanks for doing a field test. The issue reports are linked. To make developers aware which do not necessarily see these threads here ... ;) [[kgh]] (talk) 07:45, 26 October 2016 (UTC)
Saying to that using Lockdown causes 'writeapidenied' You're not allowed to edit this wiki through the API error. So in MW 1.27 VisualEditor extension can`t save page edition. 194.158.204.247 (talk) 07:27, 2 November 2016 (UTC)
As a matter of fact the MultimediaViewer extension also exits with readapidenied for MW 1.27.1 [[kgh]] (talk) 21:37, 11 November 2016 (UTC)
This is still an issue with latest code on REL1_27. Thus I have adjusted task T148582 accordingly. Let's hope for a quick fix. [[kgh]] (talk) 16:55, 20 November 2016 (UTC)
There seems to be progress on this front. A backport of https://gerrit.wikimedia.org/r/#/c/303369/ will hopefully fix the issues on REL1_27 once and for all. Keeping fingers crossed. [[kgh]] (talk) 23:36, 5 December 2016 (UTC)
Great, now that T148582 will be resolved by doing a backport to MediaWiki core with change 325566 all we have to do is wait for the MW 1.27.2 release. [[kgh]] (talk) 17:30, 6 December 2016 (UTC)
I have having this same problem and I am using 1.27.2 and the latest REL1_27 209.41.163.23 (talk) 13:32, 14 April 2017 (UTC)
I only get this for the second action the api tries to perform so effectively bulk uploads do not work. Moreover I am the only clown here actually making people aware on Phabricator so that's probably why nothing gets moving. [[kgh]] (talk) 14:11, 14 April 2017 (UTC)
Hi, I came across this issue and decided to upgrade to 1.27.3. We still seem to be encountering the issue with MsUpload. Without lockdown, logged in users can upload files fine using MsUpload. Once Lockdown is enabled, I receive the "permission denied" error, regardless of role. Is there a setting I am missing or is this still an ongoing bug? Thanks! 130.215.202.73 (talk) 02:06, 20 May 2017 (UTC)
It is indeed an ongoing bug with nobody dealing with it. MsUpload can according to my testing only upload one file at a time, which indeed makes it pretty much useless. [[kgh]] (talk) 08:56, 20 May 2017 (UTC)
Hi, any news about this issue? Is there any chance to solve it if I upgrade to 1.28?
Thanks,
Lorenzo Loman87 (talk) 10:05, 12 July 2017 (UTC)
If it is broken with 1.27 it will also be broken with 1.28 and later. Apart from that any news. It seems to be not important since hardly anybody joins the conversion on T148582. [[kgh]] (talk) 13:08, 12 July 2017 (UTC)
Ok, thanks for the information. Is there anhything to do to press to solve the issue? On wikiapiary this extension results to be used by 504 wikis...they don't seem few to me!
Bye,
Lorenzo Loman87 (talk) 14:23, 12 July 2017 (UTC)
Perhaps it is just a matter of telling on phabricator that you have the same issue. Also noting the usage my be an argument to bring forward, too. That's 504 wikis not even counting private wikis. From my experience the ratio is 50% to 50%.
If I am the only one voicing concerns and requests ... [[kgh]] (talk) 14:49, 12 July 2017 (UTC)
If $wgGroupPermissions['*']['read'] = false;
For Anonymous users access for api denied. It makes problem for MultimediaViewer extension for this users.
To solve this problem you can use (in LocalSettings.php):
$wgMediaViewerUseThumbnailGuessing = true;
(maybe $wgMediaViewerIsInBeta = true; needed.)

Scrap host (talk) 15:04, 12 December 2019 (UTC)

Permission denied error with MsUpload and Uploadwizard

I assume this is connected to the problem with the API described below, but maybe not. Lockdown version 1.27 blocks any uploads with permission denied statements for both the Extension:MsUpload and Extension:UploadWizard. The normal upload function works fine.

@Kghbln -- Looks like I spoke too soon about the problems being solved with Lockdown 1.27 Christharp (talk) 19:41, 21 October 2016 (UTC)

I guess we are talking about the same as in Not working in MW 1.27 via API. See also task T148582. [[kgh]] (talk) 08:08, 24 October 2016 (UTC)
I guess we are talking about the same as in Not working in MW 1.27 via API. See also task T148582. [[kgh]] (talk) 08:09, 24 October 2016 (UTC)

Extension Lockdown blocks permission to SimpleBatchUpload

I installed the Lockdown extension to block acces for regular users to certain special pages. Everything works fine exept it blocks the uploading of files through the SimpleBatchUpload extension even though I didn't even configured the Lockdown extension to do that. How do I enable it for everyone to upload with the SimpleBatchUpload extension so I can use both extensions without any problems? Innosflew (talk) 19:12, 28 November 2016 (UTC)

I believe that you ran into the issue described here. I'm afraid that until this is fixed you will not be able to use both extension side by side on the same wiki. [[kgh]] (talk) 19:21, 28 November 2016 (UTC)
I see. Btw are you one of the developers of this extension? If yes do you know when we can expect a fix? Innosflew (talk) 12:10, 29 November 2016 (UTC)
I am not the developer and myself eagerly waiting for a fix for some time now. Perhaps you could voice you problem on phabricator too. The more people indicate that they have an issue ... [[kgh]] (talk) 12:14, 29 November 2016 (UTC)

Unable to edit pages as an admin

I installed Lockdown to restrict access to Special:ListUsers.

Added:

require_once "$IP/extensions/Lockdown/Lockdown.php";

Added:

$wgSpecialPageLockdown['Listusers'] = array('user');

Then changed it to:

$wgSpecialPageLockdown['Listusers'] = array('user','sysop');

As a result I couldn't access Special:ListUsers as an admin and I couldn't edit any pages as they are restricted to users.

This is quite unexpected.

I'm going to have a re-read through the manual :p JamesPoulson (talk) 15:58, 4 December 2016 (UTC)

Indeed this appears quite unexpected. The settings as such look ok to me so there is perhaps something else in the water. What are we versions of MediaWiki, Lockdown and PHP you are using? Perhaps it is a bug worth reporting. [[kgh]] (talk) 20:31, 4 December 2016 (UTC)
I'm having the same issue (and really just a slew of weird issues that I can't quite pin down), using latest 1.27 from github. Lockdown from distribution for 1.27 and php7. I think it's related to this:
https://phabricator.wikimedia.org/T127456
https://phabricator.wikimedia.org/rELCK0d59ae7a7e0e3eb5a4638ba8f814a57926dada42
I think something in 1.27 broke the way users are handled. If you try to hit $wgUser in Localsettings.php with something like $wgUser->getName() you'll hit an exception somewhere in the chain since it can't access null. I ended up having to do certain things via OutputPageBeforeHTML so I knew for a fact the user was loaded.
I'm almost thinking about loading the extension on the usercan can hook and seeing if that will force a proper load order.
I'm not cool enough to understand the full scope of the application yet Ryan.lewkowicz (talk) 20:24, 5 December 2016 (UTC)
To add, this https://github.com/rlewkowicz/docker-mediawiki-stack is an exect version of my install (minus Lockdown). Parsoid is a bit weird since I have to forward through nginx becuase it wants host to be the same in localsettings and parsoid settings and if it's in containers, that doesn't work. At somepoint I'll get rest base up and running Ryan.lewkowicz (talk) 21:28, 5 December 2016 (UTC)
I cannot replicate this on MediaWiki 1.27.1 and Lockdown REL1_27. However I use PHP 5.6 for the change. Issue T127456 was indeed a pain but has been resolved. So this should not be the issue for you. T148528 is still open. Perhaps this is the one troubling you too. [[kgh]] (talk) 23:10, 5 December 2016 (UTC)
Great, now that T148582 will be resolved by doing a backport to MediaWiki core with change 325566 all we have to do is wait for the MW 1.27.2 release. [[kgh]] (talk) 17:16, 6 December 2016 (UTC)

Can't restrict editing to registered users in MW 1.27

I don't want guests to be able to edit any pages, but I want registered users to be able to. Here is my configuration:

   $wgGroupPermissions['*']['edit'] = false;
   $wgGroupPermissions['user']['edit'] = true;

This works fine until I install Lockdown. Once I do, nobody (including administrators) can edit anything. I get this error:

   You do not have permission to edit this page, for the following reason:
   The action you have requested is limited to users in the group: Users.

What gives? Entropy (talk) 23:45, 14 December 2016 (UTC)

I don't think it works with 1.27. I use the exact same options in 1.28 and it's fine, but then other crap breaks (not with lockdown, but with VE). Ryan.lewkowicz (talk) 18:02, 18 December 2016 (UTC)
This is a known issue - see the post below. But good to know that it should work with 1.28. Cavila 09:19, 27 December 2016 (UTC)

Lockdown Invoked, But Not Found

Curious, I am trying to disable Extension:Lockdown, but it is not in my LocalSettings.php as an enabled extension. Yet is does show as invoked at Special:Version.

Where else would this extension be so I can disable it?

Thanks for any help! John Morris (talk) 15:08, 18 February 2017 (UTC)

I think to remember that you are using BlueSpice. If this is the case when have a look at the "LocalSettings.BlueSpiceDistribution.php" file which is one of the four additional settings files this suite is using and comment it out there. [[kgh]] (talk) 15:48, 18 February 2017 (UTC)
Karsten thanks sir. I apologize for not mentioning that, from here on out I need to disclose that important fact about BlueSpice usage on our wiki's.
Appreciate your help. John Morris (talk) 16:42, 18 February 2017 (UTC)
Others would not have been able to answer without knowing this. Yeah, it is always better to disclose important facts about your setup. Software bundles are one of these. [[kgh]] (talk) 17:07, 18 February 2017 (UTC)

Page restriction in mediawiki1.28

Hello having mediawiki 1.28 installed. Looked for various extentions to enable page restriction(edit / new / view) for groups but couldn't find it. Please do let us know if there is any possiblities for this. Nupur.patel (talk) 12:17, 21 April 2017 (UTC)

Letting anons create a page with Page Forms (MW 1.28.1, PF 4.1)

I'm experimenting with a wiki that is mostly "locked down" except for one namespace, where anonymous users should be allowed to create new pages using a form. These users can edit and create pages with action=edit, they can edit an existing page using Page Forms - so far so good, but what they cannot do is create a new page using Page Forms. This is despite the fact that editing the namespace is enabled for anonymous users (*) as is the FormEdit special page.

You do not have permission to edit this page, for the following reason:

The action you have requested is limited to users in the group: Users.

What settings should be used to achieve this? Cavila 11:38, 3 May 2017 (UTC)

Bug (Special:Search)

When using the Advanced tab in Special:Search the "Search in namespaces:" section only shows the namespaces which had been protected through Extension:Lockdown (i.e.namespaces included in $wgNamespacePermissionLockdown variable).

The bug was observable for users with permissions granted for these lockdown namespaces as well as anonymous users.

  • Tested on: MediaWiki v1.28.2 (438c3d6) - 00:03, 1 May 2017
  • On extension branches: master, REL1_29, REL1_28

Fortunately, the problem does not exist for REL1_27.

Update

On further investigation with individual commits for finding out which commit caused the breaking changes used the Rel1_28 commit history.

Special:Search works fine up-to-the commit, Merge "The parameter to the SearchableNamespaces hook handler needs to be a…

git checkout b19a0a60a476ddbf5344395b339e928729c11f54

For whatever reason, the Special:Search bug appears in the very next commit, Consolidate hook handler code

git checkout 6ef74a58be6ee453452470f274a76b5fc5fa211b AhmadF.Cheema (talk) 09:06, 24 May 2017 (UTC)

Got this error in our wikis.
Is there any temporary fix for this bug? Deletedaccount4567435 (talk) 20:33, 23 June 2017 (UTC)
In case you are using the REL1_28 branch, run the following command, through SSH in the extensions/Lockdown directory:
git checkout b19a0a60a476ddbf5344395b339e928729c11f54 AhmadF.Cheema (talk) 22:32, 23 June 2017 (UTC)
Cool, work immediately. Thank you! Deletedaccount4567435 (talk) 19:47, 29 June 2017 (UTC)

lockdown "Difference between revisions" Page

This is really a greate extension!

Is there a possibility to lockdown the side that is shown after the "compare selected revision" at the "revision side" like shown on https://www.mediawiki.org/w/index.php?title=Extension%3AMsCatSelect&type=revision&diff=2520718&oldid=2520717 92.224.0.212 (talk) 19:00, 31 December 2017 (UTC)

Working on MW 1.30?

I am trying to get Lockdown to work on MW 1.30. After installing the git master, it show up under Special:Version. When trying to limit read access to a custom namespace with this config:

$wgNamespacePermissionLockdown[3002]['read'] = array('sysop');

actually the main namespace is limited to sysops and the custom namespace is not locked down. I was not able to lockdown the custom namespace at all. Any suggestions? Thx, Marc 79.213.181.124 (talk) 13:03, 17 January 2018 (UTC)

Were you able to get this to work? Bevenson (talk) 18:20, 27 June 2018 (UTC)

Error in Page

I don't think you create user groups by adding them to Manual:$wgGroupPermissions (at Extension:Lockdown#Managing groups). Calion (talk) 00:33, 17 February 2018 (UTC)

You can. That's not even Lockdown specific. [[kgh]] (talk) 07:20, 17 February 2018 (UTC)
To the Manual page? Calion (talk) 19:08, 17 February 2018 (UTC)

Lockdown (validate) permission

Hi all,

When I try to restrict (validate) perrmision on a specific namespace, it does not work. But it still works on other permissions such as (Edit, Delete, Read). So, is there any way to solve these problems? thanks JamesJeko (talk) 22:46, 18 March 2018 (UTC)

Lockdown.php 1.27

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Hi, it appears that Lockdown.php has been deleted from the 1.27 version. Alvarosaurus (talk) 13:01, 3 April 2018 (UTC)

Thanks for the note. I have updated the docu accordingly. [[kgh]] (talk) 13:48, 3 April 2018 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Namespace lockdown doesn't work correctly in MW 1.31

Use this instead, in your LocalSettings.php, to limit the NS_PRIVATE and NS_PRIVATE_TALK namespaces to WikiSysop and User2.

$wgHooks['ParserBeforeStrip'][] = 'LockDownFunction';
function LockDownFunction( &$parser, &$text, &$strip_state ) {
        global $wgUser;
        $title = $parser->getTitle();
        $namespace = $title->getNamespace();
        if ( $namespace === NS_PRIVATE || $namespace === NS_PRIVATE_TALK ) {
                $user = $parser->getUser();
                $userName = $user->getName();
                $allowed = array(
                        'WikiSysop',
                        'User2'
                );
                if ( in_array( $userName, $allowed )
                        || in_array( $wgUser, $allowed )
                ) {
                        return true;
                } else {
                        die("Access denied");
                }
        }
}

Maude's Ideology (talk) 06:13, 19 June 2018 (UTC)

This is Great but you have to reverse the order in in_array for it to work
in_array( $userName, $allowed )
should to be
in_array( $allowed, $userName )
Thank you so much ! I have been so tired of deprecated Extensions that dont work. 2003:D2:DBC6:8A00:ECEA:9E8D:EF51:E302 (talk) 18:23, 13 September 2018 (UTC)
## //Restrict namespace access to group privat 
$wgHooks['ParserBeforeStrip'][] = 'LockDownFunction';
function LockDownFunction( &$parser ) {
    $title = $parser->getTitle(); 
    $namespace = $title->getNamespace(); 
    //Groups in here are allowed to access
    $allowedgroups = 'privat'; 
    //Restricted namespaces
    $wgLockedNamespaces = array( '3000', '3001' ); 
    if ( in_array($namespace, $wgLockedNamespaces) ) { 
        $user = $parser->getUser(); 
        $userGroups = $user->getGroups(); 
        if ( !in_array( $allowedgroups, $userGroups )) { 
            die("<h1>Access denied, you dont have the necessary permissions to access this namespace.</h1>");
        }
        return true;
    }
}
BabunaLaguna (talk) 22:42, 13 September 2018 (UTC)
The directly above method noted by User:BabunaLaguna does not work when submitting an edit (&action=submit) to the protected namespace and instead throws out the "Access denied..." message at the end. AhmadF.Cheema (talk) 12:01, 19 November 2018 (UTC)
Tested MW 1.31.0 on PHP 7.2.12 with Lockdown (dbd06b7). Wanted to lock one namespace and talk (198 and 199). This locked all pages in the wiki! But when using array_fill in LocalSettings.php, it seems to work:
$defaultreadall['read'] = array('*');
$wgNamespacePermissionLockdown = array_fill(0,2010,$defaultreadall);
$wgNamespacePermissionLockdown[NS_INTERNAL]['read'] = array('MyAllowedGroup');
$wgNamespacePermissionLockdown[NS_INTERNAL_TALK]['read'] = array('MyAllowedGroup');
The problem was, that the Lockdown-hook sees the global array wgNamespacePermissionLockdown as a collapsed one with empty indexes removed. Instead of [198, 192] it was only [0,1] as array keys. 141.84.65.170 (talk) 10:44, 4 December 2018 (UTC)

Issues in MW 1.27.4: Namespace completely ignored, always affects main and main talk only

I downloaded and installed the MW 1.27 version in MW 1.27.4. Either, I'm not understanding the extension properly, or it does not work.

Minimal and pointless example: I'm trying allow editing in namespace 2 (user) for bots only, so I added

$wgNamespacePermissionLockdown[2]['edit'] = array('bot');

to the end of my LocalSettings.php as the only Lockdown-related line. As the result, only bots are allowed to edit namespaces 0 (main) and 1 (talk) while everyone is still able to edit the user namespace. Generally, no matter what namespace I enter, Lockdown always affects namespace 0 and 1 only. Redeemer (talk) 09:59, 27 June 2018 (UTC)

MW 1.31 - Error 500 with Lockdown

When i put in my LocalSettings.php the expresison "wfLoadExtension( 'Lockdown' );", and i try access the main page, the server returns "ERROR 500". 179.111.167.151 (talk) 12:22, 12 July 2018 (UTC)

lockdown is incompatible with WM 1.30, it seems accesscontrol extension either 112.115.94.118 (talk) 14:17, 29 July 2018 (UTC)

Use of lowercase letter in compound words of special page names

Just something to note that wasn't clear at first until I read this talk page which gives some more examples. For some special page names, only the first character is capitalized and the rest of the word is all lowercase. For example, the page is called "Special:ListUsers" in MediaWiki, but you need to call it "Listusers" (lowercase u) in the config file for it to work. This contradicts the naming of the special pages by Mediawiki. Thanks for this extension. Deltaray3 (talk) 13:21, 21 November 2018 (UTC)

Thanks for the note. However this is already documented on the extension's page There is also a difference between internal naming and user facing naming. Yeah, indeed a bit complicated at the beginning. [[kgh]] (talk) 14:41, 21 November 2018 (UTC)

createpage only permissions?

I am trying to set:


$wgNamespacePermissionLockdown[0]['createpage'] = array( 'bureaucrat', 'sysop' );


but it does not seem to work. Is it possible at all to limit page creation only? MW 1.31.1 Serek (talk) 09:58, 15 December 2018 (UTC)

Extension:Lockdown is not needed for this.
You will need to disable the createpage right for user groups. See Manual:User rights#Changing group permissions. AhmadF.Cheema (talk) 15:56, 20 March 2019 (UTC)

Extension:Lockdown not working - $wgActionLockdown and others..?

I there a bug in this - I am trying to restrict the export function (entirely limit the range of special pages) in a simple way... but it seems like nothing is working for me. (I did try to mess with the $wgGroupPermissions - but I backed that out totally - and now lockdown is the only extension!

# Lockdown start

wfLoadExtension( 'Lockdown' );

Seems like this installed correct. But neither of these restricts 'user' from going to the (special page) export page...


$wgActionLockdown['Export'] = [ 'sysop' ];

$wgSpecialPageLockdown['Export'] = [ 'user' ];


and this is what I tired initially... after/while I was logged in as sysop..

$wgNamespacePermissionLockdown[NS_SPECIAL]['*'] = [ 'sysop' ];


(version 1.32.0) AssetDenmark (talk) 08:11, 9 April 2019 (UTC)

Thanks to this Extension talk:Lockdown/Archive 2/Flow export#h-Locking_down_special_pages-2011-11-20T10:30:00.000Z - i can now exclude users from Specialpages... please look at that topic for my comments!
$wgNamespacePermissionLockdown['*']['edit'] = [ 'sysop' ];
IS working fine for me.. and I can also add namespacve permissions to selected users... like this.
$wgNamespacePermissionLockdown[NS_Baggrund]['read'] = array('user');
$wgNamespacePermissionLockdown[NS_Baggrund_TALK]['*'] = array('user');
Tip you can also add a new user group, that 'sysop' can then assigned. Say I have some namespace material that should only be available to 'user' (registered), and then some that should be available it I give permission. To create a new group, this group will be on the you must have lines (one for each group) like this in the localsettings.php:
$wgGroupPermissions['your-permisison-group']['read']   = false; AssetDenmark (talk) 08:13, 10 April 2019 (UTC)

Upgrade MW 1.34 - LockDown stops working

Hi there,


My first post here, so please be gentle!


Been working with, and administering, our private MediaWiki for close to a year now.

Set it up, including LockDown, starting with version 1.31.x (if I remember correctly).

LockDown of our custom NameSpaces has worked fine, no issues. I set it up so that a usergroup has edit/create rights within their own NameSpace, and only Read rights in all other custom NameSpaces.

Now, after upgrading MediaWiki to 1.34.0, when browsing to a page within another NameSpace, I receive an error on that page (translated from Dutch):


This page does not function

wiki.domain,name can not process this request.

HTTP ERROR 500


If I disable the extionsion LockDown in the LocalSettings.php, all pages are viewable (and editable).

Does anybody else have this problem, or a way to resolve this issue?


One of the sections from our LocalSettings.php:

wfLoadExtension( 'Lockdown' );

# Start with assigning the default permissions from group "autoconfirmed"

$wgGroupPermissions['IMTSSB_Users'] = $wgGroupPermissions['autoconfirmed'];

# Add the permissions from group "bot"

$wgGroupPermissions['IMTSSB_Users'] = array_merge($wgGroupPermissions['IMTSSB_Users'], $wgGroupPermissions['bot']);

# Now modify these rights:

$wgGroupPermissions['IMTSSB_Users']['delete'] = true;

$wgGroupPermissions['IMTSSB_Users']['protect'] = true;

$wgGroupPermissions['IMTSSB_Users']['patrol'] = true;


## Custom Namespaces

# Create Custom Namespaces

define('NS_IMTSSB', 500);

define('NS_IMTSSB_TALK', 501);

define('NS_IMTSNB', 502);

define('NS_IMTSNB_TALK', 503);

define('NS_IMTSAB', 504);


# Define Custom Namespaces

# Custom Namespace "IMTSSB" Serverbeheer

$wgExtraNamespaces[NS_IMTSSB] = 'IMTSSB';

$wgExtraNamespaces[NS_IMTSSB_TALK] = 'IMTSSB_talk';

# restrict "read" permission to anyone

$wgNamespacePermissionLockdown[NS_IMTSSB]['read'] = [ '*' ];

$wgNamespacePermissionLockdown[NS_IMTSSB_TALK]['read'] = [ '*' ];

# give all permissions to members of IMTSSB_Users group

$wgNamespacePermissionLockdown[NS_IMTSSB]['*'] = [ 'IMTSSB_Users' ];

$wgNamespacePermissionLockdown[NS_IMTSSB_TALK]['*'] = [ 'IMTSSB_Users' ];

# prevent inclusion of pages from that namespace

$wgNonincludableNamespaces[] = NS_IMTSSB;

$wgNonincludableNamespaces[] = NS_IMTSSB_TALK; IMTS-TB (talk) 12:40, 21 January 2020 (UTC)

Hide specific page except to owner?

Hi @Duesentrieb thank you for the great extension.

I wanted to ask you if Lockdown or another method would allow me to do the following.

  1. Someone creates a page. That page is automatically ONLY visible to the owner (hidden from anyone else) but the owner can also invite others to see the page.
  2. Only the owner (original creator) can edit the page, but they can allow others to edit it if they want.
  3. The owner can choose to publish the page (make it publicly visible)
  4. If they make they publish the page, the revision history of when it was private does not show, instead the revision history is reset and starts anew for the public version.

Please let me know, thank you. MavropaliasG (talk) 09:56, 26 February 2020 (UTC)

No function in MW1.31

I have problems with hackers sending me virus-mails - thats why a want to hide

http://spiritwiki.de/w/Spezial:Benutzer for all not logged in users - but

wfLoadExtension( 'Lockdown' );

$wgSpecialPageLockdown['Benutzer'] = [ 'user' ];

$wgActionLockdown['Benutzer'] = [ 'user' ];

has no effect - what is wrong ? Manbu (talk) 15:02, 7 May 2020 (UTC)

Shouldn't this read 'User' instead of 'Benutzer'? Also, on the extension page there is a small note about "Hiding pages", which appears to be possible, but it's a bit more difficult to do. Evilninja (talk) 15:48, 7 May 2020 (UTC)
No - i have of course already tried that before i post here ( special:user is redirected to Spezial:user - and http://spiritwiki.de/w/Spezial:User ... error : does not exist...). It has evtl to do with german language or with namespace /w/ ? Manbu (talk) 12:54, 8 May 2020 (UTC)

is there a way to prevend the

  • &oldid=
  • &diff=

etc. links. That would allow to hide the changes. Gunnar.offel (talk) 09:48, 11 June 2020 (UTC)

Did anyone ever figure this one out? I'd also like to block Anonymous users from diff= links. I see some IPs trying to spider every single revision on my wiki. 74.215.149.82 (talk) 18:57, 8 August 2024 (UTC)
i'm not sure how i solved it long time before. i assume it is still open, but at the moment i semi-solved, at least your topic with
$wgActionLockdown['history'] = [ 'user' ];
since the spider can't read history, they doesn't crawl old revisions and diffs.
Manually calls are still possible, sadly. Gunnar.offel (talk) 10:50, 17 September 2024 (UTC)

Hi All,

We have been running mediawiki for about 10 years and at some point started to notice issues with lockdown and visual editor for which there are many discussion pages and bugs for example: https://phabricator.wikimedia.org/T148582#4412138 https://phabricator.wikimedia.org/T148582


As our wiki is readable by all users but only editable by logged in users we hit the known issues. For several years now we have been applying a work around not to load lockdown for localhost, 127.0.0.1 and local server IP. With out this workaround protected namespaces cannot be edited. Workaround is similar to:

if ( !isset( $_SERVER['REMOTE_ADDR'] ) OR $_SERVER['REMOTE_ADDR'] == '127.0.0.1'        ) {
        $wgGroupPermissions['*']['read'] = true;
        $wgGroupPermissions['*']['edit'] = true;
} else {
wfLoadExtension("Lockdown");

        $wgGroupPermissions['*']['read'] = true;
        $wgGroupPermissions['*']['edit'] = false;
        $wgGroupPermissions['user']['read'] = true;
        $wgGroupPermissions['user']['edit'] = true;

        $wgNamespacePermissionLockdown[NS_L2]['*'] = [ 'tech-L2', 'tech-L3' ];
        $wgNamespacePermissionLockdown[NS_L3]['*'] = [ 'tech-L3' ];
}

However we have recently noticed that this intermittently breaks switching between visualeditor and source editor.


I started reading through all the aforementioned bugs, plus not a few more, and realised that this work around should no longer be necessary, however I can't get cookie forwarding to work for Parsoid JS, Restbase and VisualEditor in 1.34. Is there any chance anyone has as sample working config they are willing to share (restbase, parsoid and localsettings).


In particular I am interested to know if there are any flags that need to be added to restbase or parsoid config for cookie forwarding?


I have enabled (as well as the standard config) the following in LocalSettings:


$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;
$wgVirtualRestConfig['modules']['global']['forwardCookies'] = true;
$wgVirtualRestConfig['modules']['restbase']['forwardCookies'] = true;
$wgVisualEditorParsoidForwardCookies = true;


Are there any other flags I need to set in restbase, parsoid or LocalSettings, currently the only configuration I have relevant to cookie forwarding is in LocalSettings.php?

In our examples we can't edit the L2 and L3 namespaces. Minimum configs i could reproduce on below if anyone is feeling helpful.

Thanks in advance,

Caleb

Error in parsoid logs  
{"name":"parsoid","hostname":"testwiki.wiki.internal","pid":1173,"level":60,"logType":"fatal/request","wiki":"wiki$0","title":"L2:Test","oldId":null,"reqId":"8b724680-f202-11ea-ae20-13b87b0d14d7","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36","msg":"API response Error for TemplateRequest: request=; error={\"code\":\"accessdenied\",\"info\":\"You are not allowed to view L2:Test.\",\"*\":\"See http://testwiki.wiki.internal/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.\"}","stack":"Error: API response Error for TemplateRequest: request=; error={\"code\":\"accessdenied\",\"info\":\"You are not allowed to view L2:Test.\",\"*\":\"See http://testwiki.wiki.internal/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.\"}\n    at TemplateRequest.ApiRequest._errorObj (/var/lib/parsoid/lib/mw/ApiRequest.js:342:9)\n    at TemplateRequest._handleJSON (/var/lib/parsoid/lib/mw/ApiRequest.js:554:16)\n    at TemplateRequest.ApiRequest._logWarningsAndHandleJSON (/var/lib/parsoid/lib/mw/ApiRequest.js:447:7)\n    at TemplateRequest.ApiRequest._handleBody (/var/lib/parsoid/lib/mw/ApiRequest.js:483:7)\n    at TemplateRequest.ApiRequest._requestCB (/var/lib/parsoid/lib/mw/ApiRequest.js:420:8)\n    at Request._callback (/var/lib/parsoid/lib/mw/ApiRequest.js:332:35)\n    at Request.self.callback (/var/lib/parsoid/node_modules/request/request.js:185:22)\n    at Request.emit (events.js:315:20)\n    at Request.<anonymous> (/var/lib/parsoid/node_modules/request/request.js:1154:10)\n    at Request.emit (events.js:315:20)\n    at IncomingMessage.<anonymous> (/var/lib/parsoid/node_modules/request/request.js:1076:12)\n    at Object.onceWrapper (events.js:421:28)\n    at IncomingMessage.emit (events.js:327:22)\n    at endReadableNT (_stream_readable.js:1220:12)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)","longMsg":"API response Error for TemplateRequest: request=; error={\"code\":\"accessdenied\",\"info\":\"You are not allowed to view L2:Test.\",\"*\":\"See http://testwiki.wiki.internal/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.\"}","levelPath":"fatal/request","time":"2020-09-08T18:38:53.628Z","v":0}


Chrome console log showing 500 error  
load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:141 JQMIGRATE: Migrate is installed with logging active, version 3.0.1
VM1016:150 This page is using the deprecated ResourceLoader module "jquery.tabIndex".
(anonymous) @ VM1016:150
runScript @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:13
execute @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:15
doPropagation @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:7
requestIdleCallback (async)
requestPropagation @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:8
setAndPropagate @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:8
implement @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:20
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:1
load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:130 GET http://testwiki.wiki.internal/testwiki.wiki.internal/v1/page/html/L2%3ATest?redirect=false&stash=true 500
send @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:130
ajax @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:125
jQuery.ajax @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:144
requestParsoidData @ VM1016:148
requestPageData @ VM1016:145
(anonymous) @ VM1016:125
mightThrow @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:48
process @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
setTimeout (async)
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
fire @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:45
add @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:46
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:50
jQuery.Deferred @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:152
then @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
activateTarget @ VM1016:125
activatePageTarget @ VM1016:127
activateVe @ VM1016:135
onEditTabClick @ VM1016:134
dispatch @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:69
elemData.handle @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:65
VM1016:148 RESTBase load failed: error
(anonymous) @ VM1016:148
mightThrow @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:48
process @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
setTimeout (async)
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
fire @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:45
fireWith @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:47
fire @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:47
fire @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:45
fireWith @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:47
done @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:126
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:130
load (async)
send @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:130
ajax @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:125
jQuery.ajax @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:144
requestParsoidData @ VM1016:148
requestPageData @ VM1016:145
(anonymous) @ VM1016:125
mightThrow @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:48
process @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
setTimeout (async)
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
fire @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:45
add @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:46
(anonymous) @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:50
jQuery.Deferred @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:152
then @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:49
activateTarget @ VM1016:125
activatePageTarget @ VM1016:127
activateVe @ VM1016:135
onEditTabClick @ VM1016:134
dispatch @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:69
elemData.handle @ load.php?lang=en&modules=jquery&skin=vector&version=1xgm5:65


LocalSettings.php  
<?php

######################################################################################################################################
#CORE
######################################################################################################################################


$wgSitename = "testwiki";
$wgSecretKey = "c5ded9cb55cc68669f706ad0fffbb9e7aba3e7b7f5664b2c7448259e274d9dd6";
$wgUpgradeKey = "11640ab816b1bb22";

#Short URLs and Search Config
$wgScriptPath = "";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";


$wgServer = "http://testwiki.wiki.internal";


$wgResourceBasePath = $wgScriptPath;


######################################################################################################################################
#DATABASE
######################################################################################################################################


$wgDBtype = "mysql";
$wgDBserver = "mariadb";
$wgDBname = "wikis";
$wgDBuser = "wikisql";
$wgDBpassword = "c493905d0e184ffd23e4c53420dc9cb6d557892d";
$wgDBprefix = "";
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
$wgDBmysql5 = false;


######################################################################################################################################
#GENERAL
######################################################################################################################################

// Skin
wfLoadSkin( 'Vector' );
$wgDefaultSkin='vector';


######################################################################################################################################
#Additional Mediawiki User Groups: tech-*
######################################################################################################################################


###Tech/Engineering Groups (CREATE)
$wgGroupPermissions['tech-L2'] = $wgGroupPermissions['user'];
$wgGroupPermissions['tech-L3'] = $wgGroupPermissions['user'];


######################################################################################################################################
#Custom Namespaces
######################################################################################################################################


define('NS_L2' , 3002);
define('NS_L2_TALK' , 3003);
define('NS_L3' , 3004);
define('NS_L3_TALK' , 3005);


$wgExtraNamespaces[NS_L2] = 'L2';
$wgExtraNamespaces[NS_L2_TALK] = 'L2 Talk';
$wgExtraNamespaces[NS_L3] = 'L3';
$wgExtraNamespaces[NS_L3_TALK] = 'L3 Talk';

######################################################################################################################################
#Lockdown
######################################################################################################################################

wfLoadExtension("Lockdown");

$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['edit'] = true;

$wgNamespacePermissionLockdown[NS_L2]['*'] = [ 'tech-L2', 'tech-L3' ];
$wgNamespacePermissionLockdown[NS_L3]['*'] = [ 'tech-L3' ];


#####################################################################################################################################
#VisualEditor, Restbase and Parsoid
######################################################################################################################################


##Global Rest Config
  $wgVirtualRestConfig = [
    'modules' => [],
    'global' => [
      'domain' => 'testwiki.wiki.internal',
      'timeout' => 360,
      'forwardCookies' => true,
      'HTTPProxy' => null,
      ]
    ];


 # Rest config for Parsoid
 $wgVirtualRestConfig['modules']['parsoid'] = array(
  'url' => 'http://localhost:8142',
  'domain' => 'testwiki.wiki.internal',
  'forwardCookies' => true,
  'restbaseCompat' => false
  );


 ## Rest Config for Restbase
 $wgVirtualRestConfig['modules']['restbase'] = array(
  'url' => 'http://localhost:7231',
  'domain' => 'testwiki.wiki.internal',
  'forwardCookies' => true,
  'parsoidCompat' => false
 );


#VisualEditor
 wfLoadExtension('VisualEditor');
 $wgVisualEditorParsoidAutoConfig = false;
 $wgVisualEditorAllowLossySwitching = false;
 $wgVisualEditorFullRestbaseURL = 'http://testwiki.wiki.internal/testwiki.wiki.internal/';
 $wgVisualEditorRestbaseURL = 'http://localhost:7231/testwiki.wiki.internal/v1/page/html/';
 $wgVisualEditorParsoidForwardCookies = true;


 $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";
 $wgDefaultUserOptions['visualeditor-enable'] = 1;
 $wgDefaultUserOptions['visualeditor-newwikitext'] = 1;

 $wgVisualEditorAutoAccountEnable = true;
 $wgVisualEditorShowBetaWelcome = false;
 $wgVisualEditorEnableDiffPage = true;
 $wgVisualEditorEnableWikitext = true;

 $wgVisualEditorNamespaces = array_merge($wgContentNamespaces, array( NS_TALK, NS_USER, NS_USER_TALK, NS_L2, NS_L2_TALK, NS_L3, NS_L3_TALK) );
 $wgVisualEditorAvailableNamespaces = array_fill_keys($wgVisualEditorNamespaces, true);


config.yaml for restbase  
#
# Simple RESTBase config for Mediawiki Container
# https://www.mediawiki.org/wiki/RESTBase/Installation
#
# - cassandra DB
# - parsoid at http://localhost:8142
# - wiki at http://testwiki.wiki.internal/api.php
#
# - proxied via nginx, available via
# - http://hostname/api/rest_v1/
#
services:
  - name: restbase
    module: hyperswitch
    conf:
      port: 7231
      salt: 988881adc9fc3655077dc2d4d757d480b5ea0e11
      default_page_size: 125
      user_agent: RESTBase
      ui_name: RESTBase
      ui_url: https://www.mediawiki.org/wiki/RESTBase
      ui_title: RESTBase docs
      spec:
        x-request-filters:
          - path: lib/security_response_header_filter.js
          - path: lib/normalize_headers_filter.js
        x-sub-request-filters:
          - type: default
            name: http
            options:
              allow:
                - pattern: http://localhost/api.php
                  forward_headers: true
                - pattern: http://localhost:8142
                  forward_headers: true
                - pattern: http://testwiki.wiki.internal/api.php
                  forward_headers: true
                - pattern: http://testwiki.wiki.internal:8142
                  forward_headers: true

                - pattern: /^https?:\/\//
        paths:
          /{domain:testwiki.wiki.internal}/{api:v1}:
            x-modules:
              - spec:
                  info:
                    version: 1.0.0
                    title: Wikimedia REST API
                    description: Welcome to your RESTBase API.
                  x-route-filters:
                    - path: ./lib/normalize_title_filter.js
                      options:
                        redirect_cache_control: 's-maxage=0, max-age=86400'
                  paths:
                    /page:
                      x-modules:
                        - path: v1/content.yaml
                          options:
                            response_cache_control: 's-maxage=0, max-age=86400'
                        - path: v1/common_schemas.yaml # Doesn't really matter where to mount it.
                    /transform:
                      x-modules:
                        - path: v1/transform.yaml
                    /media:
                      x-modules:
                        #- path: v1/mathoid.yaml
                        #  options:
                        #    host: http://localhost:10042

          /{domain:testwiki.wiki.internal}/{api:sys}:
            x-modules:
              - path: projects/proxy.yaml
                options:
                  backend_host_template: '{{"/{domain}/sys/legacy"}}'
              - spec:
                  paths:
                    /table:
                      x-modules:
                        - path: sys/table.js
                          options:
                            conf:
                              version: 1
                              backend: cassandra
                              hosts:
                                - cassandradb
                              pool_idle_timeout: 20000
                              retry_delay: 250
                              retry_limit: 10
                              show_sql: false
                              keyspace: system
                              defaultConsistency: localOne
                              localDc: datacenter1
                              datacenters:
                                - datacenter1
                              storage_groups:
                                - name: local
                                  domains: /./
                    /legacy/key_value:
                      x-modules:
                        - path: sys/key_value.js
                    /legacy/page_revisions:
                      x-modules:
                        - path: sys/page_revisions.js
                    /post_data:
                      x-modules:
                        - path: sys/post_data.js
                    /action:
                      x-modules:
                        - path: sys/action.js
                          options:
                            apiUriTemplate: "{{'http://localhost/api.php'}}"
                            baseUriTemplate: "{{'http://localhost:7231/{domain}/v1'}}"
                    /page_save:
                      x-modules:
                        - path: sys/page_save.js
                    /events:
                      x-modules:
                        - path: sys/events.js
                    /parsoid:
                      x-modules:
                        - path: sys/parsoid.js
                          options:
                            parsoidHost: http://localhost:8142
                            grace_ttl: 1000000
                    #/mathoid:
                    #  x-modules:
                    #    - path: sys/mathoid.js
                    #      options:
                    #        host: http://localhost:10042

# Finally, a standard service-runner config.
info:
  name: restbase

logging:
  name: restbase
  level: warn
  streams:
    - type: stdout


num_workers: 0


config.yaml for parsoid  
worker_heartbeat_timeout: 300000
num_workers: 2

logging:
    name: parsoid
    level: warn

services:
  - module: lib/index.js
    entrypoint: apiServiceWorker
    conf:
        mwApis:
        - uri: 'http://localhost/api.php'
          domain: 'testwiki.wiki.internal'
        serverPort: 8142


nginx config  
# nginx http config for Mediawiki server
#
# this config-file is updated during container-startup
# 'testwiki.wiki.internal' is replaced globally with the FQDN of the Wiki
#


##############################
### UPSTREAMS
##############################

# restbase
upstream restbase {
  server 127.0.0.1:7231;
  keepalive 32;
}
map $request_uri $restbasequeryapi {
  default "xx";
  "~/api/rest_v1/(?<xrestbasequery>.*)$" "$xrestbasequery";
}
map $request_uri $restbasequerylegacy {
  default "xx";
  "~/testwiki.wiki.internal/v1/(?<xrestbasequery>.*)$" "$xrestbasequery";
}
map $request_uri $imageDownloadAttachment {
  default "";
  "~/images/.*(\?|&)download(=|&).*$" "attachment";
}


##############################
### MAIN HTTP SERVER
##############################

server {

  ##############################
  ### HTTP Globals
  ##############################

  server_name _;
  listen 80;
  root /var/lib/mediawiki;
  client_max_body_size 100m;
  fastcgi_connect_timeout 10s;

  set $no_cache "0";

  ##############################
  ### Proxy Restbase, Mathoid
  ##############################

  location /api/rest_v1/ {
    proxy_max_temp_file_size 0;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_http_version 1.1;
    proxy_pass http://restbase/testwiki.wiki.internal/v1/$restbasequeryapi;
    set $no_cache "1";
  }

  location /testwiki.wiki.internal/v1/ {
    proxy_max_temp_file_size 0;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_http_version 1.1;
    proxy_pass http://restbase/testwiki.wiki.internal/v1/$restbasequerylegacy;
    set $no_cache "1";
  }

  location /api/mathoid/ {
    proxy_max_temp_file_size 0;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_http_version 1.1;
    proxy_pass http://127.0.0.1:10042/;
    set $no_cache "1";
  }

 location /rest.php/ {
    proxy_max_temp_file_size 0;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_http_version 1.1;
    try_files $uri $uri/ /rest.php?$query_string;
    set $no_cache "1";
 }

 # Bypass cache if flag is set
 fastcgi_no_cache $no_cache;
 fastcgi_cache_bypass $no_cache;
 proxy_cache_bypass $no_cache;
 proxy_no_cache $no_cache;

  ##############################
  ### General Requests
  ##############################

  location ~ \.htaccess { deny all; }
  location ^~ /install-mw.sh { return 403; }
  location ^~ /update-mw.sh { return 403; }
  location ^~ /runjobs-mw.sh { return 403; }
  location ^~ /bootstrap/1_env.php { return 403; }

  location ^~ /bootstrap.php {
    # extended php-timeout ( e.g. for update.php )
    fastcgi_read_timeout 200s;
    fastcgi_send_timeout 200s;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php-fpm.sock;
    include fastcgi_params;
  }

  location /images {
    # enable CORS access to this dir from other origins
    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Expose-Headers "Age,Date,X-Cache,X-Varnish";

    # allow downloads via Media Viewer
    add_header Content-Disposition $imageDownloadAttachment;

    # the hosting root-dir is updated/set during container startup
    root /wiki-shared/testwiki/storage;

    # set the 'Expires' header for 90days of image-caching to reverse-proxies
    # proxies often have their own expiry-lifetime for hot/cold cache items
    expires 90d;
  }

  location / {
    try_files $uri @rewrite;
  }

  location ^~ /mw-config/ {
    internal;
  }

  location @rewrite {
    rewrite ^/(.*)$ /index.php;
  }

  location ^~ /maintenance/ {
    internal;
  }

  location = /_.gif {
    expires max;
    empty_gif;
  }

  location ^~ /cache/ {
    internal;
  }

  ##############################
  ### PHP Config
  ##############################

  location ~ ^/system/nginxping$ {
    access_log off;
    return 200 'pong :-)';
  }

  location ~ ^/system/phpstatus {
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php-fpm.sock;
    include fastcgi_params;
    fastcgi_index index.php;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    fastcgi_index index.php;
  }

}

Calebgcooper (talk) 17:41, 7 September 2020 (UTC)

Since writing I've tested in versions 1.31, 1.32, 1.33, 1.34 and 1.35 of mediawiki, all versions have the same issue, except when using parsoid php implementation in 1.35, in the later case there is no longer a need to use the workaround not to load lockdown when the request comes from localhost.
But unless I am doing something wrong it is hard to believe this was fixed in T148582 but maybe this is a regression.. Calebgcooper (talk) 21:13, 10 September 2020 (UTC)

PSA: Lockdown + SemanticACL + SimpleBatchUpload = Private Content in MW

This is just a PSA for those wanting a way of providing a protected namespace for private content that is also able to automatically protect files uploaded from a page in that namespace. The goal on my site was to give management a place to upload sensitive management files that are not available to non-management users. Here's how I did it:

  1. Create a custom namespace called "Management"
  2. Create a custom rights group called "management"
  3. Use "Extension:Lockdown" to protect the "Management" namespace for user in the "management" right group
  4. Use "Extension:SimpleBatchUpload" in a page in the Management namespace to provide the methods of uploading files with a template of {{Upload|viewedonlyby=management}}
  5. Modify Template:Upload to test (#ifeq) for property {{{viewonlyby|}}} in {{Uploads}},
    • if so, then add [[Visible to group::management]] to all files uploaded with that template where |viewonlyby=management.
  6. Use Extension:Semantic_ACL to limit access to the file by group management per the presence of [[Visible to group::management]].
In summary: Custom Namespace + Lockdown + SimpleBatchUpload + SemanticACL produces the overall effect.

Within the security limitations noted by MW, this method provides a very nice way of allowing management to add content that is not visible to non-management users.. a very handy thing for an enterprise site! Revansx (talk) 22:31, 8 October 2020 (UTC)

The wikitext {{#batchupload:Upload|viewonlyby=management}} will create an upload button in a page that will automatically protect any files uploaded by it as long as Template:Upload contains
{{#ifeq:{{{viewonlyby|}}}|management
| [[Visible to group::management]]
|
}}
Revansx (talk) 22:50, 8 October 2020 (UTC)

Restrict access to templates

Hi; How can access to templates be restricted to registered persons? رامي 4554 (talk) 18:15, 11 January 2021 (UTC)

You can protect them using administrator rights to "Allow only autoconfirmed users" - this will only prevent editing but not viewing Charitwo (talk) 19:41, 11 January 2021 (UTC)

Restrict access to "Page Information"

In order to restrict access to the Page Information (for ex. https://mediawiki.my.domain/index.php?title=Main_Page&action=info) for the anonymous users, I tried this:

wfLoadExtension( 'Lockdown' );

$wgSpecialPageLockdown['PageInfo'] = [ 'sysop' ];

$wgSpecialPageLockdown['Info'] = [ 'sysop' ];

but it doesn't work, the page won't be restricted. Does anybody know a solution for this? S0ring (talk) 08:47, 24 June 2021 (UTC)

These aren't special-Pages, that are actions.
so
$wgActionLockdown['info'] = [ 'user' ];
will restrict the page to user with account 89.145.60.157 (talk) 00:09, 30 September 2021 (UTC)

Conflict on Extension:Lockdown page ?

As a newbie, there seems to be such a basic conflict on the main page of this extension, I wonder if I'm missing something -

$wgSpecialPageLockdown['Export'] = [ 'user' ];

Is described in the Example to 'PREVENT access to Special:Export to logged in users (registered user)'

But in the Configuration it is described as 'to limit the use of Special:Export to logged in users' Wightbartie (talk) 10:26, 10 July 2021 (UTC)

'user' means everyone with an active account.
anonymous persons can't export with this setting.
maybe you want disallow for all or restrict to 'sysop' 89.145.60.157 (talk) 00:11, 30 September 2021 (UTC)

Restricted special pages. Using Lockdown Extension

hello i'm from indonesia sorry if i'm wrong in english.. #ask i want to create a hidden page on mediawiki so that only me can see/edit the page i tried to use extension lockdown but the problem is i can't configure it. can anyone help with my problem Ki maung (talk) 14:06, 19 September 2021 (UTC)

Deprecated Function

Hi, I just updated to MediaWiki 1.37 and get now the following error:

Use of User::getEffectiveGroups was deprecated in MediaWiki 1.35. [Called from MediaWiki\Extensions\Lockdown\Hooks::onGetUserPermissionsErrors in /var/www/html/extensions/Lockdown/src/Hooks.php at line 123] in /var/www/html/includes/debug/MWDebug.php
 on line 375

I think the code should be fixed here. I hope someone could help out. 134.3.98.147 (talk) 12:31, 6 December 2021 (UTC)

Found that in the release Notes of MW 1.35:
The following methods of the User class are deprecated: getGroups, getGroupMemberships, getEffectiveGroups, getAutomaticGroups, addGroup, removeGroup, getFormerGroups, getAllGroups, getImplicitGroups, addAutopromoteOnceGroups. Use the new UserGroupManager service instead.
So I would say, the Extension is not supported for MW 1.37. Hopefully someone will fix that. I am using the extension for so long without any trouble. 134.3.98.147 (talk) 12:38, 6 December 2021 (UTC)
Have you upgraded your extension to the newest version? I viewed the commit history and saw one commit fixing it. Lakejason0 (talk) 17:24, 13 December 2021 (UTC)
I encountered the same problem when using Lockdown from the REL1_37 branch. The commit fixing this issue is only in the master branch right now. Ideally the fix would be merged into REL1_37 so users of Mediawiki 1.37 won't have to choose the master (development) branch. 12.238.91.10 (talk) 17:39, 23 February 2022 (UTC)

Lockdown malfunction

Hi, i tried to create a new custom namespace, and a group that can edit this namespace and only this namespace, but can read all the other namespaces using the Lockdown extension. Here is the settings i made.

I'm using MW 1.35.

The new namespace is DATALAN, the new group is datalan.


define("CUST", 3001);

define("USR", 3002);

define("DATALAN", 3003);

$wgExtraNamespaces[CUST] = "Customization";

$wgExtraNamespaces[USR] = "Users_guide";

$wgExtraNamespaces[DATALAN] = "Users_guide_SVK";


$wgGroupPermissions['datalan']['read'] = true;

$wgGroupPermissions['datalan']['edit'] = true;

$wgGroupPermissions['datalan']['createpage'] = true;

$wgGroupPermissions['datalan']['delete'] = true;

$wgGroupPermissions['datalan']['move'] = false;

$wgAdminCanReadAll = true;

$wgAccessControlRedirect = false;

$wgNamespacePermissionLockdown['*']['edit'] = [ 'bureaucrat'];

$wgNamespacePermissionLockdown[CUST]['read'] = array( 'bureaucrat','reader');

$wgNamespacePermissionLockdown[USR]['read'] = array( 'bureaucrat','reader');

$wgNamespacePermissionLockdown[DATALAN]['read'] = array( 'bureaucrat','reader', 'datalan' );

$wgNamespacePermissionLockdown[DATALAN]['edit'] = array( 'datalan');


If i enable the Lockdown extension, the edit icon on the pages inside the DATALAN NS are disappearing for the users in the group datalan. The reading restrict acces works perfectly, if a user in a datalan group tries to read a page, that is in CUST namespace or the other.


I woulde be very happy if somene can help me!


Thanks! 84.236.81.191 (talk) 13:44, 5 January 2022 (UTC)

Can't Block Special Namespace

I've installed Lockdown to restrict the special namespace to sysop and cm user groups, but when testing it, it doesn't seem to work.


My LocalSettings.php contains the following:

wfLoadExtension( 'Lockdown' );

$wgNamespacePermissionLockdown[NS_SPECIAL]['*'] = [ 'sysop', 'cm' ];


Any advise? Thanks 121.200.34.78 (talk) 10:45, 6 February 2023 (UTC)

Same here.
Tried:
$wgNamespacePermissionLockdown[NS_SPECIAL]['*'] = [ 'user' ];
Perhaps is there some way to do a loop to every special page (from what array?) and set $wgSpecialPageLockdown for them. Narcis Garcia (talk) 09:50, 8 October 2023 (UTC)
This works for me to make special pages disappear to anonymous users:
$wgHooks['SpecialPage_initList'][] = function ( &$list ) {
$PagesWhiteList = array('Userlogin', 'PasswordReset', 'Categories', 'Tags', 'Search', 'Captcha');
foreach ($list as $PageName => $PageSpecs) {
if (!in_array($PageName, $PagesWhiteList) && RequestContext::getMain()->getUser()->isAnon()) {
unset( $list[$PageName] );
}
}
return true;
}; Narcis Garcia (talk) 10:23, 8 October 2023 (UTC)
Any fixes for this yet? I want to allow only a custom user group to certain pages. Special page lockdown works fine for pre-made user groups but not with custom. 71.185.78.14 (talk) 17:25, 7 August 2024 (UTC)

Requires 1.41?

I just updated my wiki to 1.40 and downloaded the newest version of Lockdown in the process. I am getting an error:

Fatal error: Uncaught ExtensionDependencyError: Lockdown is not compatible with the current MediaWiki core (version 1.40.0), it requires: >= 1.41.0. in /home/<mywikidir>/includes/registration/ExtensionRegistry.php:438 Stack trace: #0 /home/<mywikidir>/includes/registration/ExtensionRegistry.php(282): ExtensionRegistry->readFromQueue(Array) #1 /home/<mywikidir>/includes/Setup.php(282): ExtensionRegistry->loadFromQueue() #2 /home/<mywikidir>/includes/WebStart.php(92): require_once('/home/xxx/w...') #3 /home/<mywikidir>/index.php(44): require('/home/xxx/w...') #4 {main} thrown in /home/<mywikidir>/includes/registration/ExtensionRegistry.php on line 438 Tenbergen (talk) 21:15, 5 July 2023 (UTC)

If you are on MW 1.40 you cannot use master since it indeed requires MW 1.41+. You should use the version from the REL1_40 branch. The extension distributor should offer a download for MW 1.40 [[kgh]] (talk) 08:46, 6 July 2023 (UTC)
I use a script to do the updates, first pulling down the newest version of mediawiki and then doing git pulls on most extensions. Is there a way to pull things from this extension distributor by script? Tenbergen (talk) 14:22, 11 July 2023 (UTC)
Do git pull;git checkout REL1_40 in the extension's directory. [[kgh]] (talk) 16:36, 11 July 2023 (UTC)
Thank you! Do all the extensions on gerrit follow that? Ie. would I be able to use that syntax to just do a pull for the current version and subversion of mediawiki that I am pulling? Tenbergen (talk) 19:31, 11 July 2023 (UTC)
More or less. A REL1_xx branch needs to be present, which I think is the case for all extensions on Gerrit. Otherwise, replace this with the appropriate tag, e.g., 2.3, etc. [[kgh]] (talk) 07:59, 12 July 2023 (UTC)

Exclusions

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Hi,

Is there a way to whitelist pages in locked-down namespaces? I have locked down NS_Project but would like read access to Project:General_disclaimer.

Cheers, Zarathustra999 (talk) 02:11, 17 July 2023 (UTC)

I found a workaround Zarathustra999 (talk) 04:40, 17 July 2023 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

I can't edit pages protected with Lockdown in the VisualEditor

I can't edit pages protected with Lockdown in the VisualEditor. Does anyone know how to fix this?

M.J.W.B. (talk) 14:06, 24 March 2024 (UTC)

I think I already solved it, by adding this to LocalSettings.php:
$wgVisualEditorAvailableNamespaces = [
"Category" => true,
"Private" => true
]; M.J.W.B. (talk) 14:19, 24 March 2024 (UTC)

Restrict read access to all categories

Is this possible? Spiros71 (talk) 16:48, 10 October 2024 (UTC)

This should restrict to category read access to sysops:
$wgNamespacePermissionLockdown[NS_CATEGORY]['read'] = [
	'sysop'
];
[[kgh]] (talk) 08:00, 11 October 2024 (UTC)

Restrict the namespace from appearing in searches ?

When our employees search if they were to type in the namespace ie; H1: everything in H1 shows up in a dropdown search. Ideally we would like that not to be searchable. Is there a fix or existing solution for that? Compumatter (talk) 05:41, 10 November 2024 (UTC)

This is not possible with this extension. You can restrict access but not appearance in search results. [[kgh]] (talk) 18:10, 10 November 2024 (UTC)
Thank you Karsten. At least I know. That is unfortunate. I would like to see this extension lockdown access further. I am also finding that media uploaded to a lockdown namespace is also not protected. Do you know if there is a MW freelancer group where I might hire someone that has the ability to add these features? Compumatter (talk) 04:27, 11 November 2024 (UTC)
I am working with a company providing professional MediaWiki development. You may want to contact us. [[kgh]] (talk) 15:50, 11 November 2024 (UTC)
MediaWiki is simply not designed for that kind of use case, read access restrictions are bound to be "leaky". Hence the fat warning at the top of the extetension documentation.
Filtering search results based on a users access permissions would be possible in theory, but I can't think of an easy way to make that performant. You'd probably need a custom search "engine" implementation.
Karsten is right, best talk to a professional MediaWiki consultancy to analyze your use case and offer solutions. Besides Professional Wiki, a few well known ones are WikiWorks, WikiTeq, and Hallo Welt. Duesentrieb 06:45, 12 November 2024 (UTC)