Skip to content

Commit fcb8bfc

Browse files
committed
Admin: Add config disable_webservices
In order to block access to v2.php/registration.soap.php webservices.
1 parent fd1d83a commit fcb8bfc

15 files changed

+50
-12
lines changed

documentation/security.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ <h2><b>Contents</b></h2>
2525
<li><a href="#5.Files-permissions">Restricting files permissions</a></li>
2626
<li><a href="#6.HSTS">HTTP Headers Security</a></li>
2727
<li><a href="#7.Direct-web-access">Direct web access to files</a></li>
28+
<li><a href="#8.Disable-webservices">Disable webservices</a></li>
2829
</ol>
2930

3031
<h2><a name="1.Disclosing-server-info"></a>1. Disclosing server info</h2>
@@ -195,6 +196,14 @@ <h2><a name="7.Direct-web-access">Direct web access to files</a></h2>
195196
information in images, CSS or JavaScript files, you will need to update
196197
these rules to suit your needs.
197198
</p>
199+
200+
<h2><a name="8.Disable-webservices">Disable webservices</a></h2>
201+
<p>
202+
In order to disable webservices add the configuration below:
203+
<pre>
204+
$_configuration['disable_webservices'] = true;
205+
</pre>
206+
</p>
198207
<h2>Authors</h2>
199208
<ul>
200209
<li>Yannick Warnier, Zend Certified PHP Engineer, BeezNest Belgium SPRL,

main/inc/lib/api.lib.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10158,3 +10158,12 @@ function api_get_print_css(bool $getFileContents = true, bool $useWebPath = fals
1015810158

1015910159
return $cssFile;
1016010160
}
10161+
10162+
function api_protect_webservices()
10163+
{
10164+
if (api_get_configuration_value('disable_webservices')) {
10165+
echo "Webservices are disabled. \n";
10166+
echo "To enable, add \$_configuration['disable_webservices'] = true; in configuration.php";
10167+
exit;
10168+
}
10169+
}

main/install/configuration.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,9 @@
19421942
// If true then a variable will be called get_lang('CareerDiagramDisclaimer') and printed below a diagram;
19431943
//$_configuration['career_diagram_disclaimer'] = true;
19441944

1945+
// Disable webservices.
1946+
//$_configuration['disable_webservices'] = true;
1947+
19451948
// KEEP THIS AT THE END
19461949
// -------- Custom DB changes
19471950
// Add user activation by confirmation email

main/webservices/access_url.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* @package chamilo.webservices
66
*/
77
require_once __DIR__.'/../inc/global.inc.php';
8+
9+
api_protect_webservices();
10+
811
$debug = true;
912

1013
define('WS_ERROR_SECRET_KEY', 1);

main/webservices/additional_webservices.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
require_once __DIR__.'/../inc/global.inc.php';
99

10+
api_protect_webservices();
11+
1012
/**
1113
* Function to convert from ppt to png
1214
* This function is used from Chamilo Rapid Lesson.

main/webservices/api/v2.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
require_once __DIR__.'/../../inc/global.inc.php';
1818

19+
api_protect_webservices();
20+
1921
$hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : null;
2022

2123
if ($hash) {

main/webservices/cm_webservice.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2+
23
/* For licensing terms, see /license.txt */
34

45
use Chamilo\UserBundle\Entity\User;
56

6-
/**
7-
* @package chamilo.webservices
8-
*/
97
require_once __DIR__.'/../inc/global.inc.php';
108

9+
api_protect_webservices();
10+
1111
/**
1212
* Error returned by one of the methods of the web service. Contains an error code and an error message.
1313
*/

main/webservices/courses_list.rest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
require_once __DIR__.'/../inc/global.inc.php';
1515

16+
api_protect_webservices();
17+
1618
/**
1719
* Get a list of courses (code, url, title, teacher, language) and return to caller
1820
* Function registered as service. Returns strings in UTF-8.

main/webservices/courses_list.soap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/* For licensing terms, see /license.txt */
34

45
/**
@@ -14,6 +15,8 @@
1415
*/
1516
require_once __DIR__.'/../inc/global.inc.php';
1617

18+
api_protect_webservices();
19+
1720
// Create the server instance
1821
$server = new soap_server();
1922
// Initialize WSDL support

main/webservices/gradebook.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
require_once __DIR__.'/../inc/global.inc.php';
88

9+
api_protect_webservices();
10+
911
ini_set('memory_limit', -1);
1012

1113
/*

0 commit comments

Comments
 (0)