chg: [UI] Always use auth key with space in UI

pull/6586/head
Jakub Onderka 2020-11-15 14:37:27 +01:00
parent b7c01e262a
commit 8b5538c93d
6 changed files with 54 additions and 19 deletions

View File

@ -2,7 +2,8 @@
echo $this->element('genericElements/Form/genericForm', [
'data' => [
'description' => __('Authkeys are used for API access. A user can have more than one authkey, so if you would like to use separate keys per tool that queries MISP, add additional keys. Use the comment field to make identifying your keys easier.'),
'title' => __('Add auth key'),
'description' => __('Auth keys are used for API access. A user can have more than one authkey, so if you would like to use separate keys per tool that queries MISP, add additional keys. Use the comment field to make identifying your keys easier.'),
'fields' => [
[
'field' => 'user_id',

View File

@ -4,10 +4,10 @@
<div id="genericModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="genericModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="genericModalLabel"><?= __('Authkey created'); ?></h3>
<h3 id="genericModalLabel"><?= __('Auth key created'); ?></h3>
</div>
<div class="modal-body modal-body-long">
<p><?= __('Please make sure that you note down the authkey below, this is the only time the authkey is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<p><?= __('Please make sure that you note down the auth key below, this is the only time the auth key is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<p><?=__('MISP will use the first and the last 4 characters for identification purposes.')?></p>
<pre class="quickSelect"><?= h($entity['AuthKey']['authkey_raw']) ?></pre>
</div>
@ -18,8 +18,8 @@
<?php
} else {
?>
<h4><?= __('Authkey created'); ?></h4>
<p><?= __('Please make sure that you note down the authkey below, this is the only time the authkey is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<h4><?= __('Auth key created'); ?></h4>
<p><?= __('Please make sure that you note down the auth key below, this is the only time the auth key is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<p><?=__('MISP will use the first and the last 4 characters for identification purposes.')?></p>
<pre class="quickSelect"><?= h($entity['AuthKey']['authkey_raw']) ?></pre>
<a href="<?= $referer ?>" class="btn btn-primary"><?= __('I have noted down my key, take me back now') ?></a>

View File

@ -2,7 +2,7 @@
echo $this->element(
'genericElements/SingleViews/single_view',
[
'title' => 'Authkey View',
'title' => 'Auth key view',
'data' => $data,
'fields' => [
[
@ -10,11 +10,11 @@ echo $this->element(
'path' => 'AuthKey.id'
],
[
'key' => __('uuid'),
'path' => 'AuthKey.uuid'
'key' => __('UUID'),
'path' => 'AuthKey.uuid',
],
[
'key' => __('Authkey'),
'key' => __('Auth key'),
'path' => 'AuthKey',
'type' => 'authkey'
],
@ -26,7 +26,7 @@ echo $this->element(
[
'key' => __('Expiration'),
'path' => 'AuthKey.expiration',
'type' => 'date'
'type' => 'expiration'
],
[
'key' => __('User'),

View File

@ -1,7 +1,7 @@
<?php
$authKey = Hash::extract($data, $field['path']);
echo sprintf(
'<span class="red bold">%s</span>%s<span class="red bold">%s</span>',
'<span class="authkey">%s</span>%s<span class="authkey">%s</span>',
h($authKey['authkey_start']),
str_repeat('&bull;', 32),
h($authKey['authkey_end'])

View File

@ -0,0 +1,34 @@
<?php
$data = Hash::extract($data, $field['path']);
if (is_array($data)) {
if (count($data) > 1) {
$data = implode(', ', $data);
} else {
if (count($data) > 0) {
$data = $data[0];
} else {
$data = '';
}
}
}
$data = h($data);
if (is_numeric($data)) {
if ($data == 0) {
$data = '<span class="text-primary font-weight-bold">' . __('Indefinite') . '</span>';
} else {
if ($data <= time()) {
$title = __('Expired at %s', date('Y-m-d H:i:s', $data));
$data = '<span class="text-danger font-weight-bold" title="' . $title . '">' . __('Expired') . '</span>';
} else {
$data = '<span class="text-success font-weight-bold">' . date('Y-m-d H:i:s', $data) . '</span>';
}
}
}
if (!empty($field['onClick'])) {
$data = sprintf(
'<span onclick="%s">%s</span>',
$field['onClick'],
$data
);
}
echo $data;

View File

@ -112,12 +112,8 @@
'css' => array('vis', 'distribution-graph'),
'js' => array('vis', 'network-distribution-graph')
));
$current_menu = [
'admin_view' => ['menuList' => 'admin', 'menuItem' => 'viewUser'],
'view' => ['menuList' => 'globalActions', 'menuItem' => 'view']
];
echo sprintf(
'<div class="users view"><div class="row-fluid"><div class="span8" style="margin:0px;">%s</div></div>%s<div style="margin-top:20px;">%s%s</div></div>%s',
'<div class="users view"><div class="row-fluid"><div class="span8" style="margin:0px;">%s</div></div>%s<div style="margin-top:20px;">%s%s</div></div>',
sprintf(
'<h2>%s</h2>%s',
__('User %s', h($user['User']['email'])),
@ -132,7 +128,11 @@
),
__('Download user profile for data portability')
),
$me['Role']['perm_auth'] ? $this->element('/genericElements/accordion', array('title' => 'Authkeys', 'url' => '/auth_keys/index/' . h($user['User']['id']))) : '',
$this->element('/genericElements/accordion', array('title' => 'Events', 'url' => '/events/index/searchemail:' . urlencode(h($user['User']['email'])))),
$this->element('/genericElements/SideMenu/side_menu', $current_menu[$admin_view ? 'admin_view' : 'view'])
$me['Role']['perm_auth'] ? $this->element('/genericElements/accordion', array('title' => __('Auth keys'), 'url' => '/auth_keys/index/' . h($user['User']['id']))) : '',
$this->element('/genericElements/accordion', array('title' => 'Events', 'url' => '/events/index/searchemail:' . urlencode(h($user['User']['email']))))
);
$current_menu = [
'admin_view' => ['menuList' => 'admin', 'menuItem' => 'viewUser'],
'view' => ['menuList' => 'globalActions', 'menuItem' => 'view']
];
echo $this->element('/genericElements/SideMenu/side_menu', $current_menu[$admin_view ? 'admin_view' : 'view']);