perf: 优化加密 (#8206)

* perf: 优化加密

* perf: 优化加密

* perf: 优化加密传输

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2022-05-10 17:28:10 +08:00
committed by GitHub
parent b44fa64994
commit aff5b0035d
8 changed files with 98 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from captcha.fields import CaptchaField, CaptchaTextInput
from common.utils import get_logger, rsa_decrypt_by_session_pkey
from common.utils import get_logger, decrypt_password
logger = get_logger(__name__)
@@ -13,7 +13,7 @@ logger = get_logger(__name__)
class EncryptedField(forms.CharField):
def to_python(self, value):
value = super().to_python(value)
return rsa_decrypt_by_session_pkey(value)
return decrypt_password(value)
class UserLoginForm(forms.Form):

View File

@@ -56,6 +56,7 @@ def authenticate(request=None, **credentials):
for backend, backend_path in _get_backends(return_tuples=True):
# 检查用户名是否允许认证 (预先检查,不浪费认证时间)
logger.info('Try using auth backend: {}'.format(str(backend)))
if not backend.username_allow_authenticate(username):
continue

View File

@@ -241,6 +241,8 @@
</body>
{% include '_foot_js.html' %}
<script type="text/javascript" src="/static/js/plugins/jsencrypt/jsencrypt.min.js"></script>
<script type="text/javascript" src="/static/js/plugins/cryptojs/crypto-js.min.js"></script>
<script type="text/javascript" src="/static/js/plugins/buffer/buffer.min.js"></script>
<script>
function doLogin() {
//公钥加密