MediaWiki  master
MWBasicRequestAuthorizer.php
Go to the documentation of this file.
1 <?php
2 
4 
9 
17  private $user;
18 
21 
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\Rest\BasicAccess\MWBasicRequestAuthorizer\$permissionManager
PermissionManager $permissionManager
Definition: MWBasicRequestAuthorizer.php:20
MediaWiki\Rest\Handler
Definition: CompareHandler.php:3
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\__construct
__construct(RequestInterface $request, Handler $handler, UserIdentity $user, PermissionManager $permissionManager)
Definition: MWBasicRequestAuthorizer.php:22
MediaWiki\Rest\BasicAccess\BasicRequestAuthorizer\$handler
$handler
Definition: BasicRequestAuthorizer.php:17
MediaWiki\Rest\BasicAccess
Definition: BasicAuthorizerBase.php:3
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:32
MediaWiki\Rest\Handler
Definition: Handler.php:9
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\BasicRequestAuthorizer
A request authorizer which checks needsReadAccess() and needsWriteAccess() in the handler and calls i...
Definition: BasicRequestAuthorizer.php:15
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:48
MediaWiki\Rest\RequestInterface
A request interface similar to PSR-7's ServerRequestInterface.
Definition: RequestInterface.php:39
MediaWiki\$action
string $action
Cache what action this request is.
Definition: MediaWiki.php:42
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\$user
UserIdentity $user
Definition: MWBasicRequestAuthorizer.php:17
MediaWiki\Rest\BasicAccess\MWBasicRequestAuthorizer\isReadAllowed
isReadAllowed()
Check if the current user is allowed to read from the wiki.
Definition: MWBasicRequestAuthorizer.php:30
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\isAllowed
isAllowed( $action)
Definition: MWBasicRequestAuthorizer.php:39