From 10eef51a0f086ad148928ba965c330599b4765cb Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 4 Jun 2017 17:16:11 +0200 Subject: Update package for new web plugin interface --- radicale_infcloud/web/auth/.htaccess | 24 ++++++ radicale_infcloud/web/auth/common.inc | 41 ++++++++++ radicale_infcloud/web/auth/config.inc | 58 ++++++++++++++ radicale_infcloud/web/auth/cross_domain.inc | 14 ++++ .../web/auth/doc/example_config_response.xml | 88 ++++++++++++++++++++++ radicale_infcloud/web/auth/doc/readme.txt | 7 ++ radicale_infcloud/web/auth/index.php | 33 ++++++++ radicale_infcloud/web/auth/plugins/generic.inc | 58 ++++++++++++++ .../web/auth/plugins/generic_conf.inc | 12 +++ radicale_infcloud/web/auth/plugins/ldap.inc | 37 +++++++++ radicale_infcloud/web/auth/plugins/ldap_conf.inc | 12 +++ 11 files changed, 384 insertions(+) create mode 100644 radicale_infcloud/web/auth/.htaccess create mode 100644 radicale_infcloud/web/auth/common.inc create mode 100644 radicale_infcloud/web/auth/config.inc create mode 100644 radicale_infcloud/web/auth/cross_domain.inc create mode 100644 radicale_infcloud/web/auth/doc/example_config_response.xml create mode 100644 radicale_infcloud/web/auth/doc/readme.txt create mode 100644 radicale_infcloud/web/auth/index.php create mode 100644 radicale_infcloud/web/auth/plugins/generic.inc create mode 100644 radicale_infcloud/web/auth/plugins/generic_conf.inc create mode 100644 radicale_infcloud/web/auth/plugins/ldap.inc create mode 100644 radicale_infcloud/web/auth/plugins/ldap_conf.inc (limited to 'radicale_infcloud/web/auth') diff --git a/radicale_infcloud/web/auth/.htaccess b/radicale_infcloud/web/auth/.htaccess new file mode 100644 index 0000000..fb4203d --- /dev/null +++ b/radicale_infcloud/web/auth/.htaccess @@ -0,0 +1,24 @@ +##################################################################################################### +# Apache configuration (REQUIRED to prevent access for .inc files /especially config files/) +# You NEED to add the following lines into your Apache vhost configuration (without the # character): +# +# AllowOverride Limit +# = 2.3> +# Require all granted +# +# +# Order allow,deny +# Allow from all +# +# +##################################################################################################### + + + = 2.3> + Require all granted + + + Order allow,deny + Deny from all + + diff --git a/radicale_infcloud/web/auth/common.inc b/radicale_infcloud/web/auth/common.inc new file mode 100644 index 0000000..419cefb --- /dev/null +++ b/radicale_infcloud/web/auth/common.inc @@ -0,0 +1,41 @@ +\n"; + + foreach($array as $k => $v) + { + if(is_numeric($k)) + array_to_xml($v, $skip_top_closing, $level); + else + { + for($j=0; $j<$level; $j++) + $result.=" "; + + $result.="<".htmlspecialchars($k); + if($k=='resources') + $result.=" xmlns=\"urn:com.inf-it:configuration\""; + if($v=='') + $result.=" />\n"; + else + { + $result.=">"; + + if(is_array($v)) + { + $result.="\n"; + array_to_xml($v, $skip_top_closing, $level+1); + for($j=0; $j<$level; $j++) + $result.=" "; + } + else + $result.=htmlspecialchars($v); + + if($level!==0 || $skip_top_closing===false) + $result.="\n"; + } + } + } + return $result; + } +?> \ No newline at end of file diff --git a/radicale_infcloud/web/auth/config.inc b/radicale_infcloud/web/auth/config.inc new file mode 100644 index 0000000..534e524 --- /dev/null +++ b/radicale_infcloud/web/auth/config.inc @@ -0,0 +1,58 @@ +array()); + + // note: if you want to use regex values, then use one of the following formats (the second example is with regex modifier): 're:.*someregex.*[0-9]$' or 're|i:.*someregex.*[0-9]$' + // note: 'crossdomain' and 'withcredentials' are still available but there is NO REASON to use them (crossDomain is detected automatically, and I've never seen anyone who understand when to use withCredentials /there is NO REASON to set it to true!/) + // note: 'syncinterval' was removed - use globalSyncResourcesInterval in config.js instead + $config['accounts']['resources'][]=array( + 'resource'=>array( + 'type'=>array('addressbook'=>'', 'calendar'=>''), + 'href'=>(empty($_SERVER['HTTPS']) ? 'http' : 'https').'://www.server.com:80/caldav.php/'.$_SERVER['PHP_AUTH_USER'].'/', + 'hreflabel'=>'null', // if undefined or empty href value is used (see above) + 'forcereadonly'=>'null', // see auth/doc/example_config_response.xml for proper use, for example: 'forcereadonly'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re:^/caldav.php/user/collection[0-9]/$')), + 'settingsaccount'=>'true', // client properties are saved here (note: set it to true only for ONE account) + 'checkcontenttype'=>'true', // check content-type in the server response (if you cannot see data in the interface /buggy server response/ you may try to disable it) + 'delegation'=>'true', // see auth/doc/example_config_response.xml for proper use, for example: 'delegation'=>array(array('resource'=>'/caldav.php/user%40domain.com/'), array('resource'=>'re|i:^/caldav.php/a[b-x].+/$')), + 'ignorealarms'=>'false', // see auth/doc/example_config_response.xml for proper use, for example: 'ignorealarms'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re:^/caldav.php/user/collection[0-9]/$')), + 'backgroundcalendars'=>'', // see auth/doc/example_config_response.xml for proper use, for example: 'backgroundcalendars'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re|i:^/caldav.php/user/collection[0-9]/$')), + 'userauth'=>array( + 'username'=>$_SERVER['PHP_AUTH_USER'], + 'password'=>$_SERVER['PHP_AUTH_PW'] + ), + 'timeout'=>90000, + 'locktimeout'=>10000 + ) + ); + +/* + // additional accounts + $config['accounts']['resources'][]=array( + 'resource'=>array( + 'type'=>array('addressbook'=>'', 'calendar'=>''), + 'href'=>'http://www.server.com:80/caldav.php/resource/', + 'hreflabel'=>'null', // if undefined or empty href value is used (see above) + 'forcereadonly'=>'null', // see auth/doc/example_config_response.xml for proper use, for example: 'forcereadonly'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re:^/caldav.php/user/collection[0-9]/$')), + 'settingsaccount'=>'false', // client properties are saved here (note: set it to true only for ONE account) + 'checkcontenttype'=>'true', // check content-type in the server response (if you cannot see data in the interface /buggy server response/ you may try to disable it) + 'delegation'=>'true', // see auth/doc/example_config_response.xml for proper use, for example: 'delegation'=>array(array('resource'=>'/caldav.php/user%40domain.com/'), array('resource'=>'re|i:^/caldav.php/a[b-x].+/$')), + 'ignorealarms'=>'false', // see auth/doc/example_config_response.xml for proper use, for example: 'ignorealarms'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re:^/caldav.php/user/collection[0-9]/$')), + 'backgroundcalendars'=>'', // see auth/doc/example_config_response.xml for proper use, for example: 'backgroundcalendars'=>array(array('collection'=>'/caldav.php/user/collection/'), array('collection'=>'re|i:^/caldav.php/user/collection[0-9]/$')), + 'userauth'=>array( + 'username'=>$_SERVER['PHP_AUTH_USER'], + 'password'=>$_SERVER['PHP_AUTH_PW'] + ), + 'timeout'=>90000, + 'locktimeout'=>10000 + ) + ); +*/ + +?> \ No newline at end of file diff --git a/radicale_infcloud/web/auth/cross_domain.inc b/radicale_infcloud/web/auth/cross_domain.inc new file mode 100644 index 0000000..a6a10e0 --- /dev/null +++ b/radicale_infcloud/web/auth/cross_domain.inc @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/radicale_infcloud/web/auth/doc/example_config_response.xml b/radicale_infcloud/web/auth/doc/example_config_response.xml new file mode 100644 index 0000000..9568049 --- /dev/null +++ b/radicale_infcloud/web/auth/doc/example_config_response.xml @@ -0,0 +1,88 @@ + + + + + + + http://www.server.com:8080/principals/users/user/ + + null + null + false + true + true + true + false + + + user + password + + 90000 + 10000 + + + + + + + http://www.server2.com:80/caldav.php/user/ + + null + true + false + false + true + + /caldav.php/user/ + /principals/users/user%40domain.com/ + re:^/caldav.php/a[b-x].+/$ + re|i:^/caldav.php/a[b-x].+/$ + + + /caldav.php/user/collection/ + /caldav.php/user%40domain.com/collection/ + re:^/caldav.php/user/collection[0-9]/$ + re|i:^/caldav.php/user/collection[0-9]/$ + + + /caldav.php/user/collection/ + /caldav.php/user%40domain.com/collection/ + re:^/caldav.php/user/collection[0-9]/$ + re|i:^/caldav.php/user/collection[0-9]/$ + + + user + password + + 90000 + 10000 + + + + + + + https://www.server3.com:8443/caldav.php/user/ + + null + + /caldav.php/user/collection/ + /caldav.php/user%40domain.com/collection/ + re:^/caldav.php/user/collection[0-9]/$ + re|i:^/caldav.php/user/collection[0-9]/$ + + false + false + true + false + false + + + user + password + + 90000 + 10000 + + diff --git a/radicale_infcloud/web/auth/doc/readme.txt b/radicale_infcloud/web/auth/doc/readme.txt new file mode 100644 index 0000000..860d29c --- /dev/null +++ b/radicale_infcloud/web/auth/doc/readme.txt @@ -0,0 +1,7 @@ +1.) configure your auth method (see the plugins directory) and the response XML in auth/config.inc and set $config['auth_send_authenticate_header']=true +2.) configure the selected auth module in plugins/PLUGIN_conf.inc +3.) check the correct response by visiting http://your-server.com/client_dir/auth/ and entering username and password +4.) set $config['auth_send_authenticate_header']=false in auth/config.inc + +By default the generic plugin is used for basic HTTP authentication ($config['auth_method']='generic'; in config.inc). + diff --git a/radicale_infcloud/web/auth/index.php b/radicale_infcloud/web/auth/index.php new file mode 100644 index 0000000..e92f005 --- /dev/null +++ b/radicale_infcloud/web/auth/index.php @@ -0,0 +1,33 @@ + + + + 401 Authorization Required + + +

Authorization Required

+

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

+ + +HTML; + exit(0); + } + else + { + header('Content-type: text/xml; charset="utf-8"'); + header('Cache-Control: max-age=0, must-revalidate, no-cache, no-store, no-transform, private'); + echo array_to_xml($config['accounts']); + } +?> \ No newline at end of file diff --git a/radicale_infcloud/web/auth/plugins/generic.inc b/radicale_infcloud/web/auth/plugins/generic.inc new file mode 100644 index 0000000..8e6b14b --- /dev/null +++ b/radicale_infcloud/web/auth/plugins/generic.inc @@ -0,0 +1,58 @@ +\n"; + return -2; + } + else + { + $request=""; + + $out="PROPFIND ".$pluginconfig['request']." HTTP/1.1\r\n"; + $out.="Host: $hostname_clean\r\n"; + $out.="Authorization: Basic ".base64_encode($_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW'])."\r\n"; + $out.="Depth: 0\r\n"; + $out.="Content-Type: text/xml; charset=\"utf-8\"\r\n"; + $out.="Content-Length:". strlen($request)."\r\n\r\n"; + $out.=$request; + fwrite($fp, $out); + + $result=''; + if(!feof($fp)) + $result.=fgets($fp); + fclose($fp); + + if(strpos($result, 'HTTP/1.1 207')===0) + return 1; // auth successful + else + return -1; // auth unsuccessful + } + } + return 0; // empty username or password + } +?> \ No newline at end of file diff --git a/radicale_infcloud/web/auth/plugins/generic_conf.inc b/radicale_infcloud/web/auth/plugins/generic_conf.inc new file mode 100644 index 0000000..01c2b32 --- /dev/null +++ b/radicale_infcloud/web/auth/plugins/generic_conf.inc @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/radicale_infcloud/web/auth/plugins/ldap.inc b/radicale_infcloud/web/auth/plugins/ldap.inc new file mode 100644 index 0000000..f7012e5 --- /dev/null +++ b/radicale_infcloud/web/auth/plugins/ldap.inc @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/radicale_infcloud/web/auth/plugins/ldap_conf.inc b/radicale_infcloud/web/auth/plugins/ldap_conf.inc new file mode 100644 index 0000000..c9242c7 --- /dev/null +++ b/radicale_infcloud/web/auth/plugins/ldap_conf.inc @@ -0,0 +1,12 @@ + \ No newline at end of file -- cgit