Merge "ResourceLoader: Deprecate ResourceLoader::makeConfigSetScript"
[mediawiki.git] / img_auth.php
blob0906361eaae694ac6306652b5d92eaf2ae2d0792
1 <?php
2 /**
3 * The web entry point for serving non-public images to logged-in users.
5 * To use this, see https://www.mediawiki.org/wiki/Manual:Image_authorization
7 * - Set $wgUploadDirectory to a non-public directory (not web accessible)
8 * - Set $wgUploadPath to point to this file
10 * Optional Parameters
12 * - Set $wgImgAuthDetails = true if you want the reason the access was denied messages to
13 * be displayed instead of just the 403 error (doesn't work on IE anyway),
14 * otherwise it will only appear in error logs
16 * For security reasons, you usually don't want your user to know *why* access was denied,
17 * just that it was. If you want to change this, you can set $wgImgAuthDetails to 'true'
18 * in localsettings.php and it will give the user the reason why access was denied.
20 * Your server needs to support REQUEST_URI or PATH_INFO; CGI-based
21 * configurations sometimes don't.
23 * @see MediaWiki\FileRepo\AuthenticatedFileEntryPoint The implementation.
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License along
36 * with this program; if not, write to the Free Software Foundation, Inc.,
37 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 * http://www.gnu.org/copyleft/gpl.html
40 * @file
41 * @ingroup entrypoint
44 use MediaWiki\Context\RequestContext;
45 use MediaWiki\EntryPointEnvironment;
46 use MediaWiki\FileRepo\AuthenticatedFileEntryPoint;
47 use MediaWiki\MediaWikiServices;
49 define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
50 define( 'MW_ENTRY_POINT', 'img_auth' );
51 require __DIR__ . '/includes/WebStart.php';
53 ( new AuthenticatedFileEntryPoint(
54 RequestContext::getMain(),
55 new EntryPointEnvironment(),
56 MediaWikiServices::getInstance()
57 ) )->run();