diff options
author | Timo Richter <timo.richter@richter-leiterplatten.de> | 2022-04-25 09:55:08 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2022-05-12 14:11:14 +0200 |
commit | 3df364a338f91f787f996b83392bc95fe38abc2c (patch) | |
tree | aa72bff61f67be843a6df4afddc140df172685e9 | |
parent | 1560cda4490ceec300d5a86b38703ae29d6d4872 (diff) | |
download | dokuwiki-3df364a338f91f787f996b83392bc95fe38abc2c.tar.gz dokuwiki-3df364a338f91f787f996b83392bc95fe38abc2c.zip |
CORS on XMLRMPC API
This allows setting a CORS header to make the xmlrpc API accessible from
JavaScript clients directly in the browser.
-rw-r--r-- | conf/dokuwiki.php | 1 | ||||
-rw-r--r-- | inc/Remote/XmlRpcServer.php | 4 | ||||
-rw-r--r-- | lib/plugins/config/lang/de-informal/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/lang/de/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/lang/en/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.metadata.php | 1 |
6 files changed, 9 insertions, 0 deletions
diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index 0ec010715..f3267787e 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -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 diff --git a/inc/Remote/XmlRpcServer.php b/inc/Remote/XmlRpcServer.php index e1f3918dc..fec958ca7 100644 --- a/inc/Remote/XmlRpcServer.php +++ b/inc/Remote/XmlRpcServer.php @@ -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); } diff --git a/lib/plugins/config/lang/de-informal/lang.php b/lib/plugins/config/lang/de-informal/lang.php index 2d1b21964..28dc89f35 100644 --- a/lib/plugins/config/lang/de-informal/lang.php +++ b/lib/plugins/config/lang/de-informal/lang.php @@ -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'; diff --git a/lib/plugins/config/lang/de/lang.php b/lib/plugins/config/lang/de/lang.php index 548524c5d..e1d103e4b 100644 --- a/lib/plugins/config/lang/de/lang.php +++ b/lib/plugins/config/lang/de/lang.php @@ -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)'; diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php index c0f459a3c..9c3b9b655 100644 --- a/lib/plugins/config/lang/en/lang.php +++ b/lib/plugins/config/lang/en/lang.php @@ -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'; diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index aa5137c2e..a02ce9f80 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -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'); |