mirror of https://github.com/MISP/MISP
new: Add instance uuid
parent
680364225e
commit
314daa4551
|
@ -101,6 +101,11 @@ class AppController extends Controller {
|
|||
$this->loadModel('Server');
|
||||
$this->Server->serverSettingsSaveValue('Security.salt', $this->User->generateRandomPassword(32));
|
||||
}
|
||||
// Check if the instance has a UUID, if not assign one.
|
||||
if (!Configure::read('MISP.uuid')) {
|
||||
$this->loadModel('Server');
|
||||
$this->Server->serverSettingsSaveValue('MISP.uuid', CakeText::uuid());
|
||||
}
|
||||
// check if Apache provides kerberos authentication data
|
||||
$envvar = Configure::read('ApacheSecureAuth.apacheEnv');
|
||||
if (isset($_SERVER[$envvar])) {
|
||||
|
|
|
@ -1302,4 +1302,8 @@ class ServersController extends AppController {
|
|||
$this->render('ajax/update');
|
||||
}
|
||||
}
|
||||
|
||||
public function getInstanceUUID() {
|
||||
return $this->RestResponse->viewData(array('uuid' => Configure::read('MISP.uuid')), $this->response->type());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,6 +268,14 @@ class Server extends AppModel {
|
|||
'type' => 'numeric',
|
||||
'optionsSource' => 'LocalOrgs',
|
||||
),
|
||||
'uuid' => array(
|
||||
'level' => 0,
|
||||
'description' => 'The MISP instance UUID. This UUID is used to identify this instance.',
|
||||
'value' => '0',
|
||||
'errorMessage' => 'No valid UUID set',
|
||||
'test' => 'testUuid',
|
||||
'type' => 'string'
|
||||
),
|
||||
'logo' => array(
|
||||
'level' => 3,
|
||||
'description' => 'This setting is deprecated and can be safely removed.',
|
||||
|
@ -2127,6 +2135,13 @@ class Server extends AppModel {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function testUuid($value) {
|
||||
if (empty($value) || !preg_match('/^\{?[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}\}?$/', $value)) {
|
||||
return 'Invalid UUID.';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function testForSessionDefaults($value) {
|
||||
if (empty($value) || !in_array($value, array('php', 'database', 'cake', 'cache'))) {
|
||||
return 'Please choose a valid session handler. Recommended values: php or database. Alternate options are cake (cakephp file based sessions) and cache.';
|
||||
|
|
Loading…
Reference in New Issue