[Web] Show users the last known connections for SASL authentication
[Web] Feature: Log SASL authentication
This commit is contained in:
@@ -271,7 +271,7 @@ jQuery(function($){
|
||||
{"name":"role","title":"Role"},
|
||||
{"name":"remote","title":"IP"},
|
||||
{"name":"msg","title":lang.message,"style":{"word-break":"break-all"}},
|
||||
{"name":"call","title":"Call","breakpoints": "all"},
|
||||
{"name":"call","title":"Call","breakpoints": "all"}
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
@@ -301,6 +301,43 @@ jQuery(function($){
|
||||
}
|
||||
});
|
||||
}
|
||||
function draw_sasl_logs() {
|
||||
ft_api_logs = FooTable.init('#sasl_logs', {
|
||||
"columns": [
|
||||
{"name":"success","title":lang.success,"filterable": false,"style":{"width":"30px"}},
|
||||
{"name":"username","title":lang.username},
|
||||
{"name":"service","title":lang.service},
|
||||
{"name":"real_rip","title":"IP"},
|
||||
{"sorted": true,"sortValue": function(value){res = new Date(value);return res.getTime();},"direction":"DESC","name":"datetime","formatter":function date_format(datetime) { var date = new Date(datetime.replace(/-/g, "/")); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});},"title":lang.login_time,"style":{"width":"170px"}},
|
||||
],
|
||||
"rows": $.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/logs/sasl',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('Cannot draw sasl log table');
|
||||
},
|
||||
success: function (data) {
|
||||
return process_table_data(data, 'sasl_log_table');
|
||||
}
|
||||
}),
|
||||
"empty": lang.empty,
|
||||
"paging": {"enabled": true,"limit": 5,"size": log_pagination_size},
|
||||
"filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table,"connectors": false},
|
||||
"sorting": {"enabled": true},
|
||||
"on": {
|
||||
"destroy.ft.table": function(e, ft){
|
||||
$('.refresh_table').attr('disabled', 'true');
|
||||
},
|
||||
"ready.ft.table": function(e, ft){
|
||||
table_log_ready(ft, 'sasl_logs');
|
||||
},
|
||||
"after.ft.paging": function(e, ft){
|
||||
table_log_paging(ft, 'sasl_logs');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function draw_acme_logs() {
|
||||
ft_acme_logs = FooTable.init('#acme_log', {
|
||||
"columns": [
|
||||
@@ -666,6 +703,20 @@ jQuery(function($){
|
||||
item.task = '<code>' + item.task + '</code>';
|
||||
item.type = '<span class="label label-' + item.type + '">' + item.type + '</span>';
|
||||
});
|
||||
} else if (table == 'sasl_log_table') {
|
||||
$.each(data, function (i, item) {
|
||||
if (item === null) { return true; }
|
||||
item.username = escapeHtml(item.username);
|
||||
if (item.service == "smtp") { item.service = '<div class="label label-default">' + item.service.toUpperCase() + '<i class="bi bi-chevron-compact-right"></i></div>'; }
|
||||
else if (item.service == "imap") { item.service = '<div class="label label-default"><i class="bi bi-chevron-compact-left"></i> ' + item.service.toUpperCase() + '</div>'; }
|
||||
else { item.service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>'; }
|
||||
if (item.success == 0) {
|
||||
item.success = '<span class="label label-danger"><i class="bi bi-person-x-fill"></i></span>';
|
||||
}
|
||||
else {
|
||||
item.success = '<span class="label label-success"><i class="bi bi-person-check-fill"></i></span>';
|
||||
}
|
||||
});
|
||||
} else if (table == 'general_syslog') {
|
||||
$.each(data, function (i, item) {
|
||||
if (item === null) { return true; }
|
||||
@@ -750,6 +801,7 @@ jQuery(function($){
|
||||
draw_api_logs();
|
||||
draw_rl_logs();
|
||||
draw_ui_logs();
|
||||
draw_sasl_logs();
|
||||
draw_netfilter_logs();
|
||||
draw_rspamd_history();
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
|
@@ -42,6 +42,7 @@ $(document).ready(function() {
|
||||
});
|
||||
$(".arrow-toggle").on('click', function(e) { e.preventDefault(); $(this).find('.arrow').toggleClass("animation"); });
|
||||
$("#pushover_delete").click(function() { return confirm(lang.delete_ays); });
|
||||
|
||||
});
|
||||
jQuery(function($){
|
||||
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||
@@ -70,8 +71,65 @@ jQuery(function($){
|
||||
return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
||||
}
|
||||
acl_data = JSON.parse(acl);
|
||||
var last_login = $('.last_login_date').data('time');
|
||||
$('.last_login_date').text(unix_time_format(last_login));
|
||||
|
||||
$('.clear-last-logins').on('click', function () {
|
||||
if (confirm(lang.delete_ays)) {
|
||||
last_logins('reset');
|
||||
}
|
||||
})
|
||||
|
||||
function last_logins(action) {
|
||||
if (action == 'get') {
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username),
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('error reading last logins');
|
||||
},
|
||||
success: function (data) {
|
||||
$('.last-login').html();
|
||||
if (data.ui.time) {
|
||||
$('.last-login').html('<i class="bi bi-person-fill"></i> ' + lang.last_ui_login + ': ' + unix_time_format(data.ui.time));
|
||||
} else {
|
||||
$('.last-login').text(lang.no_last_login);
|
||||
}
|
||||
if (data.sasl) {
|
||||
$('.last-login').append('<ul class="list-group">');
|
||||
$.each(data.sasl, function (i, item) {
|
||||
var datetime = new Date(item.datetime.replace(/-/g, "/"));
|
||||
var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
||||
if (item.service == "smtp") { service = '<div class="label label-default">' + item.service.toUpperCase() + '<i class="bi bi-chevron-compact-right"></i></div>'; }
|
||||
else if (item.service == "imap") { service = '<div class="label label-default"><i class="bi bi-chevron-compact-left"></i> ' + item.service.toUpperCase() + '</div>'; }
|
||||
else { service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>'; }
|
||||
if (item.real_rip.startsWith("Web")) {
|
||||
real_rip = item.real_rip;
|
||||
} else {
|
||||
real_rip = '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + '</a>';
|
||||
}
|
||||
$('.last-login').append('<li class="list-group-item">' +
|
||||
local_datetime + ' ' + service + ' ' + lang.from + ' ' +
|
||||
real_rip +
|
||||
'</li>');
|
||||
})
|
||||
$('.last-login').append('</ul>');
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if (action == 'reset') {
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/get/reset-last-login/' + encodeURIComponent(mailcow_cc_username),
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
console.log('cannot reset last logins');
|
||||
},
|
||||
success: function (data) {
|
||||
last_logins('get');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function draw_tla_table() {
|
||||
ft_tla_table = FooTable.init('#tla_table', {
|
||||
@@ -132,7 +190,7 @@ jQuery(function($){
|
||||
{"name":"log","title":"Log"},
|
||||
{"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
|
||||
{"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
|
||||
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"240px","width":"240px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
||||
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"260px","width":"260px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
||||
],
|
||||
"empty": lang.empty,
|
||||
"rows": $.ajax({
|
||||
@@ -324,6 +382,7 @@ jQuery(function($){
|
||||
draw_tla_table();
|
||||
draw_wl_policy_mailbox_table();
|
||||
draw_bl_policy_mailbox_table();
|
||||
last_logins('get');
|
||||
|
||||
// FIDO2 friendly name modal
|
||||
$('#fido2ChangeFn').on('show.bs.modal', function (e) {
|
||||
|
Reference in New Issue
Block a user