MediaWiki REL1_35
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}
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
A request authorizer which checks needsReadAccess() and needsWriteAccess() in the handler and calls i...
The concrete implementation of basic read/write restrictions in MediaWiki.
__construct(RequestInterface $request, Handler $handler, UserIdentity $user, PermissionManager $permissionManager)
isWriteAllowed()
Check if the current user is allowed to write to the wiki.
isReadAllowed()
Check if the current user is allowed to read from the wiki.
Base class for REST route handlers.
Definition Handler.php:16
A request interface similar to PSR-7's ServerRequestInterface.
Interface for objects representing user identity.