X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=img_auth.php;h=7765dd3cc624a579c59b24807c3dc7b2dc619a71;hb=3b3806d27a02b487cca53d965c8052ed2a92e373;hp=2d2db9a5ed1035a448a2161cf07ac7ff112488f4;hpb=9f39206b83fea7a84cfe1a632feac2668e554619;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index 2d2db9a5ed..7765dd3cc6 100644 --- a/img_auth.php +++ b/img_auth.php @@ -2,7 +2,7 @@ /** * Image authorisation script * - * To use this, see http://www.mediawiki.org/wiki/Manual:Image_Authorization + * To use this, see https://www.mediawiki.org/wiki/Manual:Image_Authorization * * - Set $wgUploadDirectory to a non-public directory (not web accessible) * - Set $wgUploadPath to point to this file @@ -92,12 +92,17 @@ function wfImageAuthMain() { if ( strpos( $path, $prefix ) === 0 ) { $be = FileBackendGroup::singleton()->backendFromPath( $storageDir ); $filename = $storageDir . substr( $path, strlen( $prefix ) ); // strip prefix + // Check basic user authorization + if ( !RequestContext::getMain()->getUser()->isAllowed( 'read' ) ) { + wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $path ); + return; + } if ( $be->fileExists( array( 'src' => $filename ) ) ) { wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." ); $be->streamFile( array( 'src' => $filename ), array( 'Cache-Control: private', 'Vary: Cookie' ) ); } else { - wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $filename ); + wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $path ); } return; }