MediaWiki master
BasicRequestAuthorizer.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Rest\BasicAccess;
4
5use MediaWiki\Rest\Handler;
6use MediaWiki\Rest\RequestInterface;
7
15abstract class BasicRequestAuthorizer {
16
17 public function __construct(
18 protected readonly RequestInterface $request,
19 protected readonly Handler $handler,
20 ) {
21 }
22
28 public function authorize() {
29 if ( $this->handler->needsReadAccess() && !$this->isReadAllowed() ) {
30 return 'rest-read-denied';
31 }
32 if ( $this->handler->needsWriteAccess() && !$this->isWriteAllowed() ) {
33 return 'rest-write-denied';
34 }
35 return null;
36 }
37
43 abstract protected function isReadAllowed();
44
50 abstract protected function isWriteAllowed();
51}
A request authorizer which checks needsReadAccess() and needsWriteAccess() in the handler and calls i...
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.
__construct(protected readonly RequestInterface $request, protected readonly Handler $handler,)
A request interface similar to PSR-7's ServerRequestInterface.
Copyright (C) 2011-2020 Wikimedia Foundation and others.