[icinga-checkins] icinga.org: icingaweb2-module-director/feature/self-service-host-api-12915 : ObjectController: generate random API key

git at icinga.org git at icinga.org
Thu Oct 13 13:44:48 CEST 2016


Module: icingaweb2-module-director
Branch: feature/self-service-host-api-12915
Commit: 0470b0737cdae0ea915b8a2f7f6f33fd56f110d1
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=0470b0737cdae0ea915b8a2f7f6f33fd56f110d1

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 13 11:44:16 2016 +0000

ObjectController: generate random API key

---

 library/Director/Web/Controller/ObjectController.php |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php
index eb600cf..afbae63 100644
--- a/library/Director/Web/Controller/ObjectController.php
+++ b/library/Director/Web/Controller/ObjectController.php
@@ -386,6 +386,15 @@ abstract class ObjectController extends ActionController
                         );
                     }
                 } else {
+                    if (property_exists($this, 'apiHost') && $this->apiHost && $this->apiHost->isTemplate()) {
+                        $data['imports'] = $this->apiHost->object_name;
+                        $data['object_type'] = 'object';
+                        $data['api_key'] = sha1(
+                            (string) (microtime(true) * 1000000)
+                            . $data['object_name']
+                            . rand(1, 1000000)
+                        );
+                    }
                     $object = IcingaObject::createByType($type, $data, $db);
                 }
 



More information about the icinga-checkins mailing list