User:Andrujhon/Allow Parsoid Server

From MediaWiki.org
Jump to navigation Jump to search

If you're running a private wiki and don't want to enable cookie forwarding for Parsoid, you can explicitly remove read/edit restrictions in your "LocalSettings.php" file for Parsoid by checking the remote IP address.

Place this code after all other permission related config. Change 127.0.0.1 to the IP of the server on which Parsoid is running, if your wiki and Parsoid do not share the same server.

if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ) {
	$wgGroupPermissions['*']['read'] = true;
	$wgGroupPermissions['*']['edit'] = true;
}

In case you are getting PHP notices from cron like e.g. "PHP Notice: Undefined index: REMOTE_ADDR in /path/to/wiki/LocalSettings.php on line ..." use the following:

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