diff --git a/apps/assets/models/domain.py b/apps/assets/models/domain.py index 7aafab504..7fcb02c3c 100644 --- a/apps/assets/models/domain.py +++ b/apps/assets/models/domain.py @@ -144,10 +144,17 @@ class Gateway(BaseUser): key_filename=self.private_key_file, sock=sock, timeout=5) - except (paramiko.SSHException, paramiko.ssh_exception.SSHException, - paramiko.AuthenticationException, TimeoutError) as e: + except (paramiko.SSHException, + paramiko.ssh_exception.SSHException, + paramiko.ChannelException, + paramiko.AuthenticationException, + TimeoutError) as e: + + err = getattr(e, 'text', str(e)) + if err == 'Connect failed': + err = _('Connect failed') self.is_connective = False - return False, str(e) + return False, err finally: client.close() self.is_connective = True diff --git a/apps/assets/signals_handler/authbook.py b/apps/assets/signals_handler/authbook.py index 7564e738d..55abf5c55 100644 --- a/apps/assets/signals_handler/authbook.py +++ b/apps/assets/signals_handler/authbook.py @@ -1,7 +1,7 @@ from django.dispatch import receiver from django.apps import apps from simple_history.signals import pre_create_historical_record -from django.db.models.signals import post_save, pre_save, post_delete +from django.db.models.signals import post_save, pre_save, pre_delete from common.utils import get_logger from ..models import AuthBook, SystemUser @@ -28,7 +28,7 @@ def pre_create_historical_record_callback(sender, history_instance=None, **kwarg setattr(history_instance, attr, system_user_attr_value) -@receiver(post_delete, sender=AuthBook) +@receiver(pre_delete, sender=AuthBook) def on_authbook_post_delete(sender, instance, **kwargs): instance.remove_asset_admin_user_if_need() diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index b53a379e7..a4b36ac3b 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -89,9 +89,6 @@ class ClientProtocolMixin: drives_redirect = is_true(self.request.query_params.get('drives_redirect')) token = self.create_token(user, asset, application, system_user) - if system_user.login_mode == SystemUser.LOGIN_MANUAL: - options['prompt for credentials on client:i'] = '1' - if drives_redirect: options['drivestoredirect:s'] = '*' options['screen mode id:i'] = '2' if full_screen else '1' diff --git a/apps/authentication/forms.py b/apps/authentication/forms.py index 948ceabff..d4c1375e6 100644 --- a/apps/authentication/forms.py +++ b/apps/authentication/forms.py @@ -67,9 +67,9 @@ class ChallengeMixin(forms.Form): def get_user_login_form_cls(*, captcha=False): bases = [] - if settings.SECURITY_LOGIN_CAPTCHA_ENABLED and captcha: - bases.append(CaptchaMixin) if settings.SECURITY_LOGIN_CHALLENGE_ENABLED: bases.append(ChallengeMixin) + elif settings.SECURITY_LOGIN_CAPTCHA_ENABLED and captcha: + bases.append(CaptchaMixin) bases.append(UserLoginForm) return type('UserLoginForm', tuple(bases), {}) diff --git a/apps/authentication/mixins.py b/apps/authentication/mixins.py index ef76c8b74..5295d4c40 100644 --- a/apps/authentication/mixins.py +++ b/apps/authentication/mixins.py @@ -191,7 +191,10 @@ class AuthMixin(PasswordEncryptionViewMixin): raise self.partial_credential_error(error=error) def _set_partial_credential_error(self, username, ip, request): - self.partial_credential_error = partial(errors.CredentialError, username=username, ip=ip, request=request) + self.partial_credential_error = partial( + errors.CredentialError, username=username, + ip=ip, request=request + ) def get_auth_data(self, decrypt_passwd=False): request = self.request diff --git a/apps/authentication/templates/authentication/login.html b/apps/authentication/templates/authentication/login.html index c54f792c7..3dafafe51 100644 --- a/apps/authentication/templates/authentication/login.html +++ b/apps/authentication/templates/authentication/login.html @@ -147,7 +147,7 @@ {% csrf_token %}
{% if form.errors %} -

+

{% if form.non_field_errors %} {{ form.non_field_errors.as_text }} {% endif %} @@ -160,9 +160,15 @@

{% bootstrap_field form.username show_label=False %} -
- + +
+ + {% if form.password.errors %} +

+ {{ form.password.errors.as_text }} +

+ {% endif %}
{% if form.challenge %} {% bootstrap_field form.challenge show_label=False %} @@ -220,7 +226,6 @@ {% trans 'FeiShu' %} {% endif %} -
{% else %}
@@ -236,6 +241,9 @@