MediaWiki
REL1_34
MWBasicRequestAuthorizer.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Rest\BasicAccess
;
4
5
use
MediaWiki\User\UserIdentity
;
6
use
MediaWiki\Permissions\PermissionManager
;
7
use
MediaWiki\Rest\Handler
;
8
use
MediaWiki\Rest\RequestInterface
;
9
15
class
MWBasicRequestAuthorizer
extends
BasicRequestAuthorizer
{
17
private
$user
;
18
20
private
$permissionManager
;
21
22
public
function
__construct
(
RequestInterface
$request
,
Handler
$handler
,
23
UserIdentity
$user
,
PermissionManager
$permissionManager
24
) {
25
parent::__construct(
$request
,
$handler
);
26
$this->user =
$user
;
27
$this->permissionManager =
$permissionManager
;
28
}
29
30
protected
function
isReadAllowed
() {
31
return
$this->permissionManager->isEveryoneAllowed(
'read'
)
32
|| $this->
isAllowed
(
'read'
);
33
}
34
35
protected
function
isWriteAllowed
() {
36
return
$this->
isAllowed
(
'writeapi'
);
37
}
38
39
private
function
isAllowed
( $action ) {
40
return
$this->permissionManager->userHasRight( $this->user, $action );
41
}
42
}
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition
PermissionManager.php:47
MediaWiki\Rest\BasicAccess\BasicRequestAuthorizer
A request authorizer which checks needsReadAccess() and needsWriteAccess() in the handler and calls i...
Definition
BasicRequestAuthorizer.php:15
MediaWiki\Rest\BasicAccess\BasicRequestAuthorizer\$handler
$handler
Definition
BasicRequestAuthorizer.php:17
MediaWiki\Rest\BasicAccess\BasicRequestAuthorizer\$request
$request
Definition
BasicRequestAuthorizer.php:16
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer
The concrete implementation of basic read/write restrictions in MediaWiki.
Definition
MWBasicRequestAuthorizer.php:15
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\__construct
__construct(RequestInterface $request, Handler $handler, UserIdentity $user, PermissionManager $permissionManager)
Definition
MWBasicRequestAuthorizer.php:22
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\$permissionManager
PermissionManager $permissionManager
Definition
MWBasicRequestAuthorizer.php:20
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\isWriteAllowed
isWriteAllowed()
Check if the current user is allowed to write to the wiki.
Definition
MWBasicRequestAuthorizer.php:35
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\$user
UserIdentity $user
Definition
MWBasicRequestAuthorizer.php:17
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\isAllowed
isAllowed( $action)
Definition
MWBasicRequestAuthorizer.php:39
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\isReadAllowed
isReadAllowed()
Check if the current user is allowed to read from the wiki.
Definition
MWBasicRequestAuthorizer.php:30
MediaWiki\Rest\Handler
Definition
Handler.php:9
MediaWiki\Rest\RequestInterface
A request interface similar to PSR-7's ServerRequestInterface.
Definition
RequestInterface.php:39
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:32
MediaWiki\Rest\BasicAccess
Definition
BasicAuthorizerBase.php:3
MediaWiki\Rest\Handler
Definition
HelloHandler.php:3
includes
Rest
BasicAccess
MWBasicRequestAuthorizer.php
Generated on Fri Apr 5 2024 23:10:25 for MediaWiki by
1.9.8