summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2019-06-24 11:45:31 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-06-24 13:51:22 +0200
commitef61154356bbf5d98ccd40e3527cde8a736b93a3 (patch)
treec40fae6264335d7c2ff7e9007364ffd6e064cf2d /admin
parent091a2b1a689d4115d131956349732ce5924ab8dc (diff)
#915 Add API token to common_request() in web console
Add token parameter in REST API infrastructure in the web console.
Diffstat (limited to 'admin')
-rw-r--r--admin/WebConsole/includes/restfunctions.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index d9ea9a44..ec5927ac 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -25,6 +25,9 @@ define('OG_REST_PARAM_RUN', 'run');
define('OG_REST_PARAM_TYPE', 'type');
define('OG_REST_PARAM_STATE', 'state');
+$conf_file = parse_ini_file('../../etc/ogAdmRepo.cfg');
+define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['ApiToken']);
+
function common_request($command, $type, $data = null) {
$json = json_encode($data);
@@ -33,6 +36,9 @@ function common_request($command, $type, $data = null) {
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
+ OG_REST_API_TOKEN,
+ ));
switch ($type) {
default: