wiki.techinc.nl/includes/Rest/BasicAccess/BasicAuthorizerBase.php
Tim Starling 94c0baaa2f REST: basic read restrictions
Protect private wikis by providing basic read restrictions,
closely following the example of the action API.

The BasicAccess module provides a narrow interface for this
functionality, without exposing the whole session/user concept to the
router.

Also, add RouterTest and fix a bug in Router::getRelativePath() thus
discovered.

Change-Id: I82319d56f08b2eec4a585ff6dbd348ccdbadc5b5
2019-07-09 15:23:20 +10:00

28 lines
815 B
PHP

<?php
namespace MediaWiki\Rest\BasicAccess;
use MediaWiki\Rest\Handler;
use MediaWiki\Rest\RequestInterface;
/**
* An implementation of BasicAuthorizerInterface which creates a request-local
* object (a request authorizer) to do the actual authorization.
*
* @internal
*/
abstract class BasicAuthorizerBase implements BasicAuthorizerInterface {
public function authorize( RequestInterface $request, Handler $handler ) {
return $this->createRequestAuthorizer( $request, $handler )->authorize();
}
/**
* Create a BasicRequestAuthorizer to authorize the request.
*
* @param RequestInterface $request
* @param Handler $handler
* @return BasicRequestAuthorizer
*/
abstract protected function createRequestAuthorizer( RequestInterface $request,
Handler $handler ) : BasicRequestAuthorizer;
}