Page MenuHomeWickedGov Phorge

ApiHookHandler.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ApiHookHandler.php

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Extension\CentralAuth\Hooks\Handlers;
use MediaWiki\Api\ApiBase;
use MediaWiki\Api\ApiMain;
use MediaWiki\Api\Hook\APIGetAllowedParamsHook;
use MediaWiki\Config\Config;
use Wikimedia\ParamValidator\ParamValidator;
class ApiHookHandler implements APIGetAllowedParamsHook {
private Config $config;
public function __construct( Config $config ) {
$this->config = $config;
}
/**
* Inject the "centralauthtoken" parameter into the API
* @param ApiBase $module API module
* @param array &$params Array of parameter specifications
* @param int $flags
* @return bool
*/
public function onAPIGetAllowedParams( $module, &$params, $flags ) {
if ( !$this->config->get( 'CentralAuthCookies' ) ) {
return true;
}
if ( $module instanceof ApiMain ) {
$params['centralauthtoken'] = [
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_SENSITIVE => true,
];
}
return true;
}
}

File Metadata

Mime Type
text/x-php
Expires
Wed, Aug 19, 02:07 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
94/a0/58cf8e8714b91a44e7cc6b06acab
Default Alt Text
ApiHookHandler.php (1 KB)

Event Timeline