summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/ogagent.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2016-07-05 11:58:39 +0000
committerramon <ramongomez@us.es>2016-07-05 11:58:39 +0000
commit210ee85d68c030148e80f4ee10578503518fc416 (patch)
tree24820cc196666f0e8b7e4305fd5805da79aacf22 /admin/WebConsole/rest/ogagent.php
parent83de7cb3b941a1426a2f7af796e25281ff25abf3 (diff)
#718: Aproximación para incluir seguridad en la comunicación OGAgent-OpenGnsys, incluyendo una clave de seguridad aleatoria en la operación de inicio de OGAgent que deberá ser utilizada posteriormente por el servidor OpenGnsys.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4978 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/ogagent.php')
-rw-r--r--admin/WebConsole/rest/ogagent.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/admin/WebConsole/rest/ogagent.php b/admin/WebConsole/rest/ogagent.php
index 95e35aad..55eeb9ba 100644
--- a/admin/WebConsole/rest/ogagent.php
+++ b/admin/WebConsole/rest/ogagent.php
@@ -12,12 +12,20 @@ define('LOG_FILE', '/opt/opengnsys/log/ogagent.log');
// OGAgent notifies that its service is started on client.
$app->post('/ogagent/started',
function() use ($app) {
-
try {
// Reading POST parameters in JSON format.
$input = json_decode($app->request()->getBody());
$ip = htmlspecialchars($input->ip);
$mac = htmlspecialchars($input->mac);
+ // Client secret key for secure communications.
+ if (isset($input->secret)) {
+ $secret = htmlspecialchars($input->secret);
+ // Store secret key in DB.
+ //...
+ } else {
+ // Insecure agent exception.
+ throw new Exception("Insecure agent: ip=$ip, mac=$mac");
+ }
// May check that client is included in the server database?
// Default processing: log activity.
file_put_contents(LOG_FILE, date(DATE_RSS).": OGAgent started: ip=$ip, mac=$mac.\n", FILE_APPEND);
@@ -36,7 +44,6 @@ $app->post('/ogagent/started',
// OGAgent notifies that its service is stopped on client.
$app->post('/ogagent/stopped',
function() use ($app) {
-
try {
// Reading POST parameters in JSON format.
$input = json_decode($app->request()->getBody());