Page MenuHomeWickedGov Phorge

BasicRequestAuthorizer.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

BasicRequestAuthorizer.php

<?php
namespace MediaWiki\Rest\BasicAccess;
use MediaWiki\Rest\Handler;
use MediaWiki\Rest\RequestInterface;
/**
* A request authorizer which checks needsReadAccess() and needsWriteAccess() in the
* handler and calls isReadAllowed() and/or isWriteAllowed() in the subclass
* accordingly.
*
* @internal
*/
abstract class BasicRequestAuthorizer {
protected RequestInterface $request;
protected Handler $handler;
/**
* @param RequestInterface $request
* @param Handler $handler
*/
public function __construct( RequestInterface $request, Handler $handler ) {
$this->request = $request;
$this->handler = $handler;
}
/**
* @see BasicAuthorizerInterface::authorize()
* @return string|null If the request is denied, the string error code. If
* the request is allowed, null.
*/
public function authorize() {
if ( $this->handler->needsReadAccess() && !$this->isReadAllowed() ) {
return 'rest-read-denied';
}
if ( $this->handler->needsWriteAccess() && !$this->isWriteAllowed() ) {
return 'rest-write-denied';
}
return null;
}
/**
* Check if the current user is allowed to read from the wiki
*
* @return bool
*/
abstract protected function isReadAllowed();
/**
* Check if the current user is allowed to write to the wiki
*
* @return bool
*/
abstract protected function isWriteAllowed();
}

File Metadata

Mime Type
text/x-php
Expires
Sat, May 16, 13:30 (1 d, 21 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
21/a1/e6763a93f96050adc1957dabdd31
Default Alt Text
BasicRequestAuthorizer.php (1 KB)

Event Timeline