Refactor authentication handling to replace getAuthenticatedOperator with requireAuthenticatedOperator in multiple files
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
This commit is contained in:
parent
885553121d
commit
ae672d7d38
6 changed files with 7 additions and 7 deletions
|
@ -250,6 +250,7 @@
|
||||||
$path === '/operators' && $requestMethod === 'GET' => Method::LIST_OPERATORS,
|
$path === '/operators' && $requestMethod === 'GET' => Method::LIST_OPERATORS,
|
||||||
$path === '/operators' && $requestMethod === 'POST' => Method::CREATE_OPERATOR,
|
$path === '/operators' && $requestMethod === 'POST' => Method::CREATE_OPERATOR,
|
||||||
$path === '/operators/self' && $requestMethod === 'GET' => Method::GET_SELF_OPERATOR,
|
$path === '/operators/self' && $requestMethod === 'GET' => Method::GET_SELF_OPERATOR,
|
||||||
|
$path === '/operators/refresh' && $requestMethod === 'POST' => Method::REFRESH_OPERATOR_API_KEY,
|
||||||
preg_match('#^/operators/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'GET' => Method::GET_OPERATOR,
|
preg_match('#^/operators/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'GET' => Method::GET_OPERATOR,
|
||||||
preg_match('#^/operators/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'DELETE' => Method::DELETE_OPERATOR,
|
preg_match('#^/operators/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'DELETE' => Method::DELETE_OPERATOR,
|
||||||
preg_match('#^/operators/([a-fA-F0-9\-]{36,})/enable$#', $path) && $requestMethod === 'POST' => Method::ENABLE_OPERATOR,
|
preg_match('#^/operators/([a-fA-F0-9\-]{36,})/enable$#', $path) && $requestMethod === 'POST' => Method::ENABLE_OPERATOR,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace FederationServer;
|
namespace FederationServer;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use FederationServer\Classes\Enums\HttpResponseCode;
|
||||||
use FederationServer\Classes\Enums\Method;
|
use FederationServer\Classes\Enums\Method;
|
||||||
use FederationServer\Classes\Logger;
|
use FederationServer\Classes\Logger;
|
||||||
use FederationServer\Classes\RequestHandler;
|
use FederationServer\Classes\RequestHandler;
|
||||||
|
@ -151,7 +152,7 @@
|
||||||
$operator = self::getAuthenticatedOperator();
|
$operator = self::getAuthenticatedOperator();
|
||||||
if ($operator === null)
|
if ($operator === null)
|
||||||
{
|
{
|
||||||
throw new RequestException('Authentication required', 401);
|
throw new RequestException('Authentication required', HttpResponseCode::UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $operator;
|
return $operator;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
$authenticatedOperator = FederationServer::requireAuthenticatedOperator();
|
||||||
if(!$authenticatedOperator->canManageOperators())
|
if(!$authenticatedOperator->canManageOperators())
|
||||||
{
|
{
|
||||||
throw new RequestException('Insufficient permissions manage permissions', 403);
|
throw new RequestException('Insufficient permissions manage permissions', 403);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
$authenticatedOperator = FederationServer::requireAuthenticatedOperator();
|
||||||
if(!$authenticatedOperator->canManageOperators())
|
if(!$authenticatedOperator->canManageOperators())
|
||||||
{
|
{
|
||||||
throw new RequestException('Insufficient permissions manage permissions', 403);
|
throw new RequestException('Insufficient permissions manage permissions', 403);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
$authenticatedOperator = FederationServer::requireAuthenticatedOperator();
|
||||||
if(!$authenticatedOperator->canManageOperators())
|
if(!$authenticatedOperator->canManageOperators())
|
||||||
{
|
{
|
||||||
throw new RequestException('Insufficient permissions manage permissions', 403);
|
throw new RequestException('Insufficient permissions manage permissions', 403);
|
||||||
|
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
$authenticatedOperator = FederationServer::requireAuthenticatedOperator();
|
||||||
|
|
||||||
$operatorUuid = null;
|
|
||||||
if(preg_match('#^/operators/([a-fA-F0-9\-]{36,})/refresh$#', FederationServer::getPath(), $matches))
|
if(preg_match('#^/operators/([a-fA-F0-9\-]{36,})/refresh$#', FederationServer::getPath(), $matches))
|
||||||
{
|
{
|
||||||
$operatorUuid = $matches[1];
|
$operatorUuid = $matches[1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue