CORS on XMLRMPC API

This allows setting a CORS header to make the xmlrpc API accessible from
JavaScript clients directly in the browser.
This commit is contained in:
Timo Richter 2022-04-25 09:55:08 +02:00 committed by Andreas Gohr
parent 1560cda449
commit 3df364a338
6 changed files with 9 additions and 0 deletions

View File

@ -66,6 +66,7 @@ $conf['auth_security_timeout'] = 900; //time (seconds) auth data is considere
$conf['securecookie'] = 1; //never send HTTPS cookies via HTTP
$conf['remote'] = 0; //Enable/disable remote interfaces
$conf['remoteuser'] = '!!not set!!'; //user/groups that have access to remote interface (comma separated). leave empty to allow all users
$conf['remotecors'] = ''; //enable Cross-Origin Resource Sharing (CORS) for the remote interfaces. Asterisk (*) to allow all origins. leave empty to deny.
/* Antispam Features */
$conf['usewordblock']= 1; //block spam based on words? 0|1

View File

@ -32,6 +32,10 @@ class XmlRpcServer extends Server
if (!$conf['remote']) {
throw new ServerException("XML-RPC server not enabled.", -32605);
}
if (!empty($conf['remotecors'])) {
header('Access-Control-Allow-Origin: ' . $conf['remotecors']);
}
parent::serve($data);
}

View File

@ -96,6 +96,7 @@ $lang['auth_security_timeout'] = 'Zeitüberschreitung bei der Authentifizierung
$lang['securecookie'] = 'Sollen Cookies, die via HTTPS gesetzt wurden nur per HTTPS versendet werden? Deaktiviere diese Option, wenn nur der Login deines Wikis mit SSL gesichert ist, aber das Betrachten des Wikis ungesichert geschieht.';
$lang['remote'] = 'Aktiviert den externen API-Zugang. Diese Option erlaubt es externen Anwendungen von außen auf die XML-RPC-Schnittstelle oder anderweitigen Schnittstellen zuzugreifen.';
$lang['remoteuser'] = 'Zugriff auf die externen Schnittstellen durch kommaseparierte Angabe von Benutzern oder Gruppen einschränken. Ein leeres Feld erlaubt Zugriff für jeden.';
$lang['remotecors'] = 'Erlaubt externen Clients API-Zugriff per Cross-Origin Resource Sharing (CORS). Asterisk (*), um alle Quellen zu erlauben. Leer lassen, um CORS zu deaktivieren.';
$lang['usewordblock'] = 'Blockiere Spam basierend auf der Wortliste';
$lang['relnofollow'] = 'rel="nofollow" verwenden';
$lang['indexdelay'] = 'Zeit bevor Suchmaschinenindexierung erlaubt ist';

View File

@ -110,6 +110,7 @@ $lang['auth_security_timeout'] = 'Authentifikations-Timeout (Sekunden)';
$lang['securecookie'] = 'Sollen Cookies, die via HTTPS gesetzt wurden nur per HTTPS versendet werden? Deaktivieren Sie diese Option, wenn nur der Login Ihres Wikis mit SSL gesichert ist, aber das Betrachten des Wikis ungesichert geschieht.';
$lang['remote'] = 'Aktiviert den externen API-Zugang. Diese Option erlaubt es externen Anwendungen von außen auf die XML-RPC-Schnittstelle oder anderweitigen Schnittstellen zu zugreifen.';
$lang['remoteuser'] = 'Zugriff auf die externen Schnittstellen durch kommaseparierte Angabe von Benutzern oder Gruppen einschränken. Ein leeres Feld erlaubt Zugriff für jeden.';
$lang['remotecors'] = 'Erlaubt externen Clients API-Zugriff per Cross-Origin Resource Sharing (CORS). Asterisk (*), um alle Quellen zu erlauben. Leer lassen, um CORS zu deaktivieren.';
$lang['usewordblock'] = 'Spam-Blocking (nach Wörterliste) benutzen';
$lang['relnofollow'] = 'rel="nofollow" verwenden';
$lang['indexdelay'] = 'Zeit bevor Suchmaschinenindexierung erlaubt ist (in Sekunden)';

View File

@ -108,6 +108,7 @@ $lang['auth_security_timeout'] = 'Authentication Security Timeout (seconds)';
$lang['securecookie'] = 'Should cookies set via HTTPS only be sent via HTTPS by the browser? Disable this option when only the login of your wiki is secured with SSL but browsing the wiki is done unsecured.';
$lang['remote'] = 'Enable the remote API system. This allows other applications to access the wiki via XML-RPC or other mechanisms.';
$lang['remoteuser'] = 'Restrict remote API access to the comma separated groups or users given here. Leave empty to give access to everyone.';
$lang['remotecors'] = 'Enable Cross-Origin Resource Sharing (CORS) for the remote interfaces. Asterisk (*) to allow all origins. Leave empty to deny CORS.';
/* Anti-Spam Settings */
$lang['usewordblock']= 'Block spam based on wordlist';

View File

@ -160,6 +160,7 @@ $meta['auth_security_timeout'] = array('numeric');
$meta['securecookie'] = array('onoff');
$meta['remote'] = array('onoff','_caution' => 'security');
$meta['remoteuser'] = array('string');
$meta['remotecors'] = array('string', '_caution' => 'security');
$meta['_anti_spam'] = array('fieldset');
$meta['usewordblock']= array('onoff');