Jump to content
MediaWiki

API:API के उपयोग को सीमित करना

From mediawiki.org
This page is a translated version of the page API:Restricting API usage and the translation is 72% complete.
Outdated translations are marked like this.
यह पृष्ठ मीडियाविकि प्रतिक्रिया API प्रलेख का हिस्सा है।
मीडियाविकि प्रतिक्रिया API
बुनियाद
प्रमाणीकरण
अकाउंट और सदस्य
पृष्ठ पर काम
खोजें
विकासक उपकरण
ट्यूटोरियल
दे · वा ·

API (के कुछ हिस्सों) के उपयोग को सीमित करने के या फिर इसे पूरी तरह से अक्षम कर देने के कई तरीके हैं। इनमें से कुछ के लिए सदस्य समूह बदलने की ज़रूरत पड़ सकती है।

Disabling general access

There is no dedicated user permission for accessing the API. To disable API access for a specific user group, you can disable read permissions for that group. For instance, to disallow anonymous requests,

$wgGroupPermissions['*']['read'] = false;

Note that some API modules may be available regardless. If access is successfully prevented, the API output will usually show the error code 'readapidenied'.

मोडल अक्षम करना

आप LocalSettings.php पर एक पंक्ति जोड़कर विशिष्ट मोडलों को सभी सदस्यों के लिए अक्षम कर सकते हैं। जोड़ना क्या है, यह उस मोडल के प्रकार पर निर्भर है जिसे आप अक्षम करना चाहते हैं:

  • action= मोडलों के लिए $wgAPIModules ['modulename'] = 'ApiDisabled'; का इस्तेमाल करें
  • prop= मोडलों के लिए $wgAPIPropModules ['modulename'] = 'ApiQueryDisabled'; का इस्तेमाल करें
  • list= मोडलों के लिए $wgAPIListModules ['modulename'] = 'ApiQueryDisabled'; का इस्तेमाल करें
  • meta= मोडलों के लिए $wgAPIMetaModules ['modulename'] = 'ApiQueryDisabled'; का इस्तेमाल करें

उदाहरण

बिना sysop अधिकार के सदस्यों के लिए action=edit का उपयोग अक्षम करना:

$wgAPIModules['edit'] = 'ApiDisabled';

API ऐक्शन को सीमित करने के लिए ApiCheckCanExecute के लिए यह हुक जोड़ें:

static function onApiCheckCanExecute( $module, $user, &$message ) {
 $moduleName = $module->getModuleName();
 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
 if (
 $moduleName == 'action' &&
 !$permissionManager->userHasRight( $user, 'right' )
 ) {
 $message = 'apierror-action-notallowed';
 return false;
 }
 return true;
}

'action', 'right' और 'apierror-action-notallowed' को उनके वैल्यूओं से बदल दें।

AltStyle によって変換されたページ (->オリジナル) /