diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-03-03 20:36:08 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-03-03 20:36:08 +0100 |
commit | 445e8084b0ae168ce8982503d16c69a64ebc5871 (patch) | |
tree | 4440bab793650c669c934e2c83cb0ac8596b1310 | |
parent | 926d4c4ee81addd5526208e038d4b78dbad4bece (diff) | |
download | rpg-445e8084b0ae168ce8982503d16c69a64ebc5871.tar.gz rpg-445e8084b0ae168ce8982503d16c69a64ebc5871.tar.bz2 |
Support login in XMLRCP and added API version info
A simple version number was added to the XMLRPC API to make it
easy for clients to check if the remote endpoint supports certain
features.
The login function will take credentials and set cookies on
successful login. This is useful when HTTP Basic auth is not
available.
darcs-hash:20090303193608-7ad00-45b1cd7a5165656796df25ed5c4ebc6e8ef7f95a.gz
-rw-r--r-- | lib/exe/xmlrpc.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index ee0ab52ed..24338da8b 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -4,6 +4,10 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); // fix when '<?xml' isn't on the very first line if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); +/** + * Increased whenever the API is changed + */ +define('DOKU_XMLRPC_API_VERSION',1); require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/common.php'); @@ -33,6 +37,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { /* DokuWiki's own methods */ $this->addCallback( + 'dokuwiki.getXMLRPCAPIVersion', + 'this:getAPIVersion', + array('integer'), + 'Returns the XMLRPC API version.' + ); + + $this->addCallback( 'dokuwiki.getVersion', 'getVersion', array('string'), @@ -40,6 +51,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { ); $this->addCallback( + 'dokuwiki.login', + 'this:login', + array('integer','string','string'), + 'Tries to login with the given credentials and sets auth cookies.' + ); + + $this->addCallback( 'dokuwiki.getPagelist', 'this:readNamespace', array('struct','string','struct'), @@ -825,6 +843,21 @@ dbglog($data); ); } + function getAPIVersion(){ + return DOKU_XMLRPC_API_VERSION; + } + + function login($user,$pass){ + global $conf; + global $auth; + if(!$conf['useacl']) return 0; + if(!$auth) return 0; + if($auth->canDo('external')){ + return $auth->trustExternal($user,$pass,false); + }else{ + return auth_login($user,$pass,false,true); + } + } } $server = new dokuwiki_xmlrpc_server(); |