mirror of https://github.com/tp4a/teleport
完成弱密码的服务端检测。
parent
58b2192753
commit
e73b7c5f6b
|
@ -76,7 +76,7 @@ $app.on_init = function (cb_stack) {
|
||||||
function (ret) {
|
function (ret) {
|
||||||
if (ret.code === TPE_OK) {
|
if (ret.code === TPE_OK) {
|
||||||
g_header = ret.data;
|
g_header = ret.data;
|
||||||
console.log('header', g_header);
|
// console.log('header', g_header);
|
||||||
|
|
||||||
$('#recorder-info').html(tp_format_datetime(g_header.start) + ': ' + g_header.user_name + '@' + g_header.client_ip + ' 访问 ' + g_header.account + '@' + g_header.conn_ip + ':' + g_header.conn_port);
|
$('#recorder-info').html(tp_format_datetime(g_header.start) + ': ' + g_header.user_name + '@' + g_header.client_ip + ' 访问 ' + g_header.account + '@' + g_header.conn_ip + ':' + g_header.conn_port);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ $app.on_init = function (cb_stack) {
|
||||||
pause();
|
pause();
|
||||||
});
|
});
|
||||||
$app.dom.progress.mouseup(function () {
|
$app.dom.progress.mouseup(function () {
|
||||||
console.log(g_current_time);
|
// console.log(g_current_time);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
init();
|
init();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
|
@ -304,8 +304,5 @@ function tp_check_strong_password(p) {
|
||||||
s |= 8;
|
s |= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((s&1) && (s&2) && (s&4))
|
return !!((s & 1) && (s & 2) && (s & 4));
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ $app.on_init = function (cb_stack) {
|
||||||
if (event.which === 13) {
|
if (event.which === 13) {
|
||||||
$app.on_set_new_password();
|
$app.on_set_new_password();
|
||||||
} else {
|
} else {
|
||||||
|
$app.hide_op_box();
|
||||||
$('[data-toggle="popover"]').popover('hide');
|
$('[data-toggle="popover"]').popover('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -231,7 +232,7 @@ $app.on_set_new_password = function () {
|
||||||
|
|
||||||
if ($app.options.force_strong) {
|
if ($app.options.force_strong) {
|
||||||
if (!tp_check_strong_password(str_password)) {
|
if (!tp_check_strong_password(str_password)) {
|
||||||
$app.show_op_box('error', '抱歉,不能使用弱密码!');
|
$app.show_op_box('error', tp_error_msg(TPE_FAILED, '抱歉,不能使用弱密码!'));
|
||||||
$app.dom.set_password.input_password.attr('data-content', "请设置强密码:至少8位,必须包含大写字母、小写字母以及数字!").focus().popover('show');
|
$app.dom.set_password.input_password.attr('data-content', "请设置强密码:至少8位,必须包含大写字母、小写字母以及数字!").focus().popover('show');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,6 +195,28 @@ def tp_md5file(file_name):
|
||||||
return m.hexdigest()
|
return m.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def tp_check_strong_password(p):
|
||||||
|
s = 0
|
||||||
|
if len(p) < 8:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for i in range(len(p)):
|
||||||
|
c = ord(p[i])
|
||||||
|
if 48 <= c <= 57: # 数字
|
||||||
|
s |= 1
|
||||||
|
elif 65 <= c <= 90: # 大写字母
|
||||||
|
s |= 2
|
||||||
|
elif 97 <= c <= 122: # 小写字母
|
||||||
|
s |= 4
|
||||||
|
else:
|
||||||
|
s |= 8
|
||||||
|
|
||||||
|
if (s & 1) and (s & 2) and (s & 4):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class UniqueId:
|
class UniqueId:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
import builtins
|
import builtins
|
||||||
|
@ -215,4 +237,3 @@ def tp_unique_id():
|
||||||
if '__tp_unique_id__' not in builtins.__dict__:
|
if '__tp_unique_id__' not in builtins.__dict__:
|
||||||
builtins.__dict__['__tp_unique_id__'] = UniqueId()
|
builtins.__dict__['__tp_unique_id__'] = UniqueId()
|
||||||
return builtins.__dict__['__tp_unique_id__'].generate()
|
return builtins.__dict__['__tp_unique_id__'].generate()
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ from app.base import mail
|
||||||
from app.model import user
|
from app.model import user
|
||||||
from app.model import group
|
from app.model import group
|
||||||
from app.logic.auth.password import tp_password_generate_secret
|
from app.logic.auth.password import tp_password_generate_secret
|
||||||
|
from app.base.utils import tp_check_strong_password
|
||||||
import tornado.gen
|
import tornado.gen
|
||||||
from app.base.logger import *
|
from app.base.logger import *
|
||||||
from app.base.controller import TPBaseHandler, TPBaseJsonHandler
|
from app.base.controller import TPBaseHandler, TPBaseJsonHandler
|
||||||
|
@ -537,6 +538,11 @@ class DoResetPasswordHandler(TPBaseJsonHandler):
|
||||||
except:
|
except:
|
||||||
return self.write_json(TPE_PARAM)
|
return self.write_json(TPE_PARAM)
|
||||||
|
|
||||||
|
# 根据需要进行弱密码检测
|
||||||
|
if get_cfg().sys.password.force_strong:
|
||||||
|
if not tp_check_strong_password(password):
|
||||||
|
return self.write_json(TPE_FAILED, '抱歉,不能使用弱密码!')
|
||||||
|
|
||||||
err, user_id = user.check_reset_token(token)
|
err, user_id = user.check_reset_token(token)
|
||||||
if err != TPE_OK:
|
if err != TPE_OK:
|
||||||
return self.write_json(err)
|
return self.write_json(err)
|
||||||
|
|
Loading…
Reference in New Issue