From 41a5a691643c955367c7dedaa2b723dda82fe836 Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Fri, 14 Jun 2019 10:36:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[Update]=20=E9=82=AE=E4=BB=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B9=EF=BC=9A?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=B4=A6=E5=8F=B7=20(#2795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/tasks.py | 3 +- apps/jumpserver/settings.py | 1 + apps/locale/zh/LC_MESSAGES/django.mo | Bin 76615 -> 76824 bytes apps/locale/zh/LC_MESSAGES/django.po | 140 ++++++++++++++------------- apps/settings/api.py | 4 +- apps/settings/forms.py | 9 +- apps/settings/serializers.py | 1 + 7 files changed, 89 insertions(+), 69 deletions(-) diff --git a/apps/common/tasks.py b/apps/common/tasks.py index dec738921..465f46eb1 100644 --- a/apps/common/tasks.py +++ b/apps/common/tasks.py @@ -24,7 +24,8 @@ def send_mail_async(*args, **kwargs): if len(args) == 3: args = list(args) args[0] = settings.EMAIL_SUBJECT_PREFIX + args[0] - args.insert(2, settings.EMAIL_HOST_USER) + email_from = settings.EMAIL_FROM or settings.EMAIL_HOST_USER + args.insert(2, email_from) args = tuple(args) try: diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index d43006c85..7f88e980a 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -353,6 +353,7 @@ EMAIL_HOST = 'smtp.jumpserver.org' EMAIL_PORT = 25 EMAIL_HOST_USER = 'noreply@jumpserver.org' EMAIL_HOST_PASSWORD = '' +EMAIL_FROM = '' EMAIL_USE_SSL = False EMAIL_USE_TLS = False EMAIL_SUBJECT_PREFIX = '[JMS] ' diff --git a/apps/locale/zh/L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?-fNY;wm)+A z8UMle1y^;P(=_X<{3~iir7M-U\n" "Language-Team: Jumpserver team\n" @@ -742,7 +742,7 @@ msgstr "密码或密钥密码" #: authentication/forms.py:13 #: authentication/templates/authentication/login.html:67 #: authentication/templates/authentication/new_login.html:93 -#: settings/forms.py:103 users/forms.py:15 users/forms.py:27 +#: settings/forms.py:110 users/forms.py:15 users/forms.py:27 #: users/templates/users/reset_password.html:53 #: users/templates/users/user_password_authentication.html:18 #: users/templates/users/user_password_update.html:43 @@ -809,7 +809,7 @@ msgstr "使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig" #: assets/templates/assets/user_asset_list.html:45 #: assets/templates/assets/user_asset_list.html:167 #: audits/templates/audits/login_log_list.html:54 -#: perms/templates/perms/asset_permission_asset.html:55 settings/forms.py:133 +#: perms/templates/perms/asset_permission_asset.html:55 settings/forms.py:140 #: users/templates/users/user_granted_asset.html:45 #: users/templates/users/user_group_granted_asset.html:45 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:51 @@ -826,7 +826,7 @@ msgstr "IP" #: assets/templates/assets/user_asset_list.html:44 #: assets/templates/assets/user_asset_list.html:166 #: perms/templates/perms/asset_permission_asset.html:54 -#: perms/templates/perms/asset_permission_list.html:77 settings/forms.py:132 +#: perms/templates/perms/asset_permission_list.html:77 settings/forms.py:139 #: users/templates/users/user_granted_asset.html:44 #: users/templates/users/user_group_granted_asset.html:44 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:50 @@ -2633,7 +2633,7 @@ msgstr "等待任务开始" msgid "Interval" msgstr "间隔" -#: ops/models/adhoc.py:38 settings/forms.py:151 +#: ops/models/adhoc.py:38 settings/forms.py:158 msgid "Units: seconds" msgstr "单位: 秒" @@ -2970,7 +2970,7 @@ msgstr "命令执行" msgid "Organization" msgstr "组织管理" -#: perms/const.py:18 settings/forms.py:136 +#: perms/const.py:18 settings/forms.py:143 msgid "All" msgstr "全部" @@ -3229,29 +3229,29 @@ msgstr "远程应用授权远程应用列表" msgid "Test mail sent to {}, please check" msgstr "邮件已经发送{}, 请检查" -#: settings/api.py:52 +#: settings/api.py:54 msgid "Test ldap success" msgstr "连接LDAP成功" -#: settings/api.py:89 +#: settings/api.py:91 msgid "Match {} s users" msgstr "匹配 {} 个用户" -#: settings/api.py:158 +#: settings/api.py:160 msgid "succeed: {} failed: {} total: {}" msgstr "成功:{} 失败:{} 总数:{}" -#: settings/api.py:180 settings/api.py:216 +#: settings/api.py:182 settings/api.py:218 msgid "" "Error: Account invalid (Please make sure the information such as Access key " "or Secret key is correct)" msgstr "错误:账户无效 (请确保 Access key 或 Secret key 等信息正确)" -#: settings/api.py:186 settings/api.py:222 +#: settings/api.py:188 settings/api.py:224 msgid "Create succeed" msgstr "创建成功" -#: settings/api.py:204 settings/api.py:242 +#: settings/api.py:206 settings/api.py:244 #: settings/templates/settings/terminal_setting.html:154 msgid "Delete succeed" msgstr "删除成功" @@ -3292,56 +3292,64 @@ msgstr "SMTP账号" msgid "SMTP password" msgstr "SMTP密码" -#: settings/forms.py:83 -msgid "Some provider use token except password" -msgstr "一些邮件提供商需要输入的是Token" +#: settings/forms.py:84 +msgid "Tips: Some provider use token except password" +msgstr "提示:一些邮件提供商需要输入的是Token" -#: settings/forms.py:86 +#: settings/forms.py:87 +msgid "Send user" +msgstr "发送账号" + +#: settings/forms.py:89 +msgid "Tips: Send mail account, default SMTP account as the send account" +msgstr "提示:发送邮件账号,默认使用 SMTP账号 作为发送账号" + +#: settings/forms.py:93 msgid "Use SSL" msgstr "使用SSL" -#: settings/forms.py:87 +#: settings/forms.py:94 msgid "If SMTP port is 465, may be select" msgstr "如果SMTP端口是465,通常需要启用SSL" -#: settings/forms.py:90 +#: settings/forms.py:97 msgid "Use TLS" msgstr "使用TLS" -#: settings/forms.py:91 +#: settings/forms.py:98 msgid "If SMTP port is 587, may be select" msgstr "如果SMTP端口是587,通常需要启用TLS" -#: settings/forms.py:97 +#: settings/forms.py:104 msgid "LDAP server" msgstr "LDAP地址" -#: settings/forms.py:100 +#: settings/forms.py:107 msgid "Bind DN" msgstr "绑定DN" -#: settings/forms.py:107 +#: settings/forms.py:114 msgid "User OU" msgstr "用户OU" -#: settings/forms.py:108 +#: settings/forms.py:115 msgid "Use | split User OUs" msgstr "使用|分隔各OU" -#: settings/forms.py:112 +#: settings/forms.py:119 msgid "User search filter" msgstr "用户过滤器" -#: settings/forms.py:113 +#: settings/forms.py:120 #, python-format msgid "Choice may be (cn|uid|sAMAccountName)=%(user)s)" msgstr "可能的选项是(cn或uid或sAMAccountName=%(user)s)" -#: settings/forms.py:116 +#: settings/forms.py:123 msgid "User attr map" msgstr "LDAP属性映射" -#: settings/forms.py:118 +#: settings/forms.py:125 msgid "" "User attr map present how to map LDAP user attr to jumpserver, username,name," "email is jumpserver attr" @@ -3349,39 +3357,39 @@ msgstr "" "用户属性映射代表怎样将LDAP中用户属性映射到jumpserver用户上,username, name," "email 是jumpserver的属性" -#: settings/forms.py:127 +#: settings/forms.py:134 msgid "Enable LDAP auth" msgstr "启用LDAP认证" -#: settings/forms.py:137 +#: settings/forms.py:144 msgid "Auto" msgstr "自动" -#: settings/forms.py:144 +#: settings/forms.py:151 msgid "Password auth" msgstr "密码认证" -#: settings/forms.py:147 +#: settings/forms.py:154 msgid "Public key auth" msgstr "密钥认证" -#: settings/forms.py:150 +#: settings/forms.py:157 msgid "Heartbeat interval" msgstr "心跳间隔" -#: settings/forms.py:154 +#: settings/forms.py:161 msgid "List sort by" msgstr "资产列表排序" -#: settings/forms.py:157 +#: settings/forms.py:164 msgid "List page size" msgstr "资产分页每页数量" -#: settings/forms.py:160 +#: settings/forms.py:167 msgid "Session keep duration" msgstr "会话保留时长" -#: settings/forms.py:161 +#: settings/forms.py:168 msgid "" "Units: days, Session, record, command will be delete if more than duration, " "only in database" @@ -3389,62 +3397,62 @@ msgstr "" "单位:天。 会话、录像、命令记录超过该时长将会被删除(仅影响数据库存储, oss等不" "受影响)" -#: settings/forms.py:165 +#: settings/forms.py:172 msgid "Telnet login regex" msgstr "Telnet 成功正则表达式" -#: settings/forms.py:166 +#: settings/forms.py:173 msgid "ex: Last\\s*login|success|成功" msgstr "" "登录telnet服务器成功后的提示正则表达式,如: Last\\s*login|success|成功 " -#: settings/forms.py:177 +#: settings/forms.py:184 msgid "MFA Secondary certification" msgstr "MFA 二次认证" -#: settings/forms.py:179 +#: settings/forms.py:186 msgid "" "After opening, the user login must use MFA secondary authentication (valid " "for all users, including administrators)" msgstr "开启后,用户登录必须使用MFA二次认证(对所有用户有效,包括管理员)" -#: settings/forms.py:185 +#: settings/forms.py:192 msgid "Batch execute commands" msgstr "批量命令" -#: settings/forms.py:186 +#: settings/forms.py:193 msgid "Allow user batch execute commands" msgstr "允许用户批量执行命令" -#: settings/forms.py:191 +#: settings/forms.py:198 msgid "Limit the number of login failures" msgstr "限制登录失败次数" -#: settings/forms.py:195 +#: settings/forms.py:202 msgid "No logon interval" msgstr "禁止登录时间间隔" -#: settings/forms.py:197 +#: settings/forms.py:204 msgid "" "Tip: (unit/minute) if the user has failed to log in for a limited number of " "times, no login is allowed during this time interval." msgstr "" "提示:(单位:分)当用户登录失败次数达到限制后,那么在此时间间隔内禁止登录" -#: settings/forms.py:204 +#: settings/forms.py:211 msgid "Connection max idle time" msgstr "SSH最大空闲时间" -#: settings/forms.py:206 +#: settings/forms.py:213 msgid "" "If idle time more than it, disconnect connection(only ssh now) Unit: minute" msgstr "提示:(单位:分)如果超过该配置没有操作,连接会被断开(仅ssh)" -#: settings/forms.py:212 +#: settings/forms.py:219 msgid "Password expiration time" msgstr "密码过期时间" -#: settings/forms.py:214 +#: settings/forms.py:221 msgid "" "Tip: (unit: day) If the user does not update the password during the time, " "the user password will expire failure;The password expiration reminder mail " @@ -3454,81 +3462,81 @@ msgstr "" "提示:(单位:天)如果用户在此期间没有更新密码,用户密码将过期失效; 密码过期" "提醒邮件将在密码过期前5天内由系统(每天)自动发送给用户" -#: settings/forms.py:223 +#: settings/forms.py:230 msgid "Password minimum length" msgstr "密码最小长度 " -#: settings/forms.py:227 +#: settings/forms.py:234 msgid "Must contain capital letters" msgstr "必须包含大写字母" -#: settings/forms.py:229 +#: settings/forms.py:236 msgid "" "After opening, the user password changes and resets must contain uppercase " "letters" msgstr "开启后,用户密码修改、重置必须包含大写字母" -#: settings/forms.py:234 +#: settings/forms.py:241 msgid "Must contain lowercase letters" msgstr "必须包含小写字母" -#: settings/forms.py:235 +#: settings/forms.py:242 msgid "" "After opening, the user password changes and resets must contain lowercase " "letters" msgstr "开启后,用户密码修改、重置必须包含小写字母" -#: settings/forms.py:240 +#: settings/forms.py:247 msgid "Must contain numeric characters" msgstr "必须包含数字字符" -#: settings/forms.py:241 +#: settings/forms.py:248 msgid "" "After opening, the user password changes and resets must contain numeric " "characters" msgstr "开启后,用户密码修改、重置必须包含数字字符" -#: settings/forms.py:246 +#: settings/forms.py:253 msgid "Must contain special characters" msgstr "必须包含特殊字符" -#: settings/forms.py:247 +#: settings/forms.py:254 msgid "" "After opening, the user password changes and resets must contain special " "characters" msgstr "开启后,用户密码修改、重置必须包含特殊字符" -#: settings/forms.py:254 +#: settings/forms.py:261 msgid "Create user email subject" msgstr "创建用户邮件的主题" -#: settings/forms.py:255 +#: settings/forms.py:262 msgid "" "Tips: When creating a user, send the subject of the email (eg:Create account " "successfully)" msgstr "提示: 创建用户时,发送设置密码邮件的主题 (例如: 创建用户成功)" -#: settings/forms.py:259 +#: settings/forms.py:266 msgid "Create user honorific" msgstr "创建用户邮件的敬语" -#: settings/forms.py:260 +#: settings/forms.py:267 msgid "Tips: When creating a user, send the honorific of the email (eg:Hello)" msgstr "提示: 创建用户时,发送设置密码邮件的敬语 (例如: 您好)" -#: settings/forms.py:265 +#: settings/forms.py:272 msgid "Create user email content" msgstr "创建用户邮件的内容" -#: settings/forms.py:266 +#: settings/forms.py:273 msgid "Tips:When creating a user, send the content of the email" msgstr "提示: 创建用户时,发送设置密码邮件的内容" -#: settings/forms.py:269 +#: settings/forms.py:276 msgid "Signature" msgstr "署名" -#: settings/forms.py:270 +#: settings/forms.py:277 msgid "Tips: Email signature (eg:jumpserver)" msgstr "提示: 邮件的署名 (例如: jumpserver)" diff --git a/apps/settings/api.py b/apps/settings/api.py index 29986637e..d399d207c 100644 --- a/apps/settings/api.py +++ b/apps/settings/api.py @@ -30,6 +30,7 @@ class MailTestingAPI(APIView): def post(self, request): serializer = self.serializer_class(data=request.data) if serializer.is_valid(): + email_from = serializer.validated_data["EMAIL_FROM"] email_host_user = serializer.validated_data["EMAIL_HOST_USER"] for k, v in serializer.validated_data.items(): if k.startswith('EMAIL'): @@ -37,7 +38,8 @@ class MailTestingAPI(APIView): try: subject = "Test" message = "Test smtp setting" - send_mail(subject, message, email_host_user, [email_host_user]) + email_from = email_from or email_host_user + send_mail(subject, message, email_from, [email_host_user]) except Exception as e: return Response({"error": str(e)}, status=401) diff --git a/apps/settings/forms.py b/apps/settings/forms.py index 228abb7ec..78fab4801 100644 --- a/apps/settings/forms.py +++ b/apps/settings/forms.py @@ -80,7 +80,14 @@ class EmailSettingForm(BaseForm): ) EMAIL_HOST_PASSWORD = FormEncryptCharField( max_length=1024, label=_("SMTP password"), widget=forms.PasswordInput, - required=False, help_text=_("Some provider use token except password") + required=False, + help_text=_("Tips: Some provider use token except password") + ) + EMAIL_FROM = forms.CharField( + max_length=128, label=_("Send user"), initial='', required=False, + help_text=_( + "Tips: Send mail account, default SMTP account as the send account" + ) ) EMAIL_USE_SSL = forms.BooleanField( label=_("Use SSL"), initial=False, required=False, diff --git a/apps/settings/serializers.py b/apps/settings/serializers.py index 731823df9..e0fdb0383 100644 --- a/apps/settings/serializers.py +++ b/apps/settings/serializers.py @@ -6,6 +6,7 @@ class MailTestSerializer(serializers.Serializer): EMAIL_PORT = serializers.IntegerField(default=25) EMAIL_HOST_USER = serializers.CharField(max_length=1024) EMAIL_HOST_PASSWORD = serializers.CharField() + EMAIL_FROM = serializers.CharField(required=False, allow_blank=True) EMAIL_USE_SSL = serializers.BooleanField(default=False) EMAIL_USE_TLS = serializers.BooleanField(default=False) From 50443de888b4fa7ba80a040e07f6eb98c8119172 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Thu, 20 Jun 2019 11:25:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=88=B7=E8=A2=AB=E6=8E=88=E6=9D=83=E7=9A=84?= =?UTF-8?q?RemoteApp=E5=88=97=E8=A1=A8=E5=8A=A0=E8=BD=BD=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/api/user_group_permission.py | 7 ------- apps/perms/api/user_permission.py | 11 +++++++---- apps/perms/mixins.py | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/apps/perms/api/user_group_permission.py b/apps/perms/api/user_group_permission.py index 159f76a39..841a82096 100644 --- a/apps/perms/api/user_group_permission.py +++ b/apps/perms/api/user_group_permission.py @@ -93,19 +93,12 @@ class UserGroupGrantedNodesWithAssetsAsTreeApi(ListAPIView): show_assets = True system_user_id = None - def change_org_if_need(self): - if self.request.user.is_superuser or \ - self.request.user.is_app or \ - self.kwargs.get('pk') is None: - set_to_root_org() - def get(self, request, *args, **kwargs): self.show_assets = request.query_params.get('show_assets', '1') == '1' self.system_user_id = request.query_params.get('system_user') return super().get(request, *args, **kwargs) def get_queryset(self): - self.change_org_if_need() user_group_id = self.kwargs.get('pk', '') queryset = [] group = get_object_or_404(UserGroup, id=user_group_id) diff --git a/apps/perms/api/user_permission.py b/apps/perms/api/user_permission.py index b4f8fc07e..c4e86f4bd 100644 --- a/apps/perms/api/user_permission.py +++ b/apps/perms/api/user_permission.py @@ -25,7 +25,9 @@ from ..hands import ( NodeSerializer, RemoteAppSerializer, ) from .. import serializers, const -from ..mixins import AssetsFilterMixin, RemoteAppFilterMixin +from ..mixins import ( + AssetsFilterMixin, RemoteAppFilterMixin, ChangeOrgIfNeedMixin +) from ..models import Action logger = get_logger(__name__) @@ -460,7 +462,7 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, APIView): # RemoteApp permission -class UserGrantedRemoteAppsApi(RemoteAppFilterMixin, ListAPIView): +class UserGrantedRemoteAppsApi(ChangeOrgIfNeedMixin, RemoteAppFilterMixin, ListAPIView): permission_classes = (IsOrgAdminOrAppUser,) serializer_class = RemoteAppSerializer pagination_class = LimitOffsetPagination @@ -485,7 +487,7 @@ class UserGrantedRemoteAppsApi(RemoteAppFilterMixin, ListAPIView): return super().get_permissions() -class UserGrantedRemoteAppsAsTreeApi(ListAPIView): +class UserGrantedRemoteAppsAsTreeApi(ChangeOrgIfNeedMixin, ListAPIView): serializer_class = TreeNodeSerializer permission_classes = (IsOrgAdminOrAppUser,) @@ -517,10 +519,11 @@ class UserGrantedRemoteAppsAsTreeApi(ListAPIView): return super().get_permissions() -class ValidateUserRemoteAppPermissionApi(APIView): +class ValidateUserRemoteAppPermissionApi(ChangeOrgIfNeedMixin, APIView): permission_classes = (IsOrgAdminOrAppUser,) def get(self, request, *args, **kwargs): + self.change_org_if_need(request, kwargs) user_id = request.query_params.get('user_id', '') remote_app_id = request.query_params.get('remote_app_id', '') user = get_object_or_404(User, id=user_id) diff --git a/apps/perms/mixins.py b/apps/perms/mixins.py index f302285a6..f1d7fac1e 100644 --- a/apps/perms/mixins.py +++ b/apps/perms/mixins.py @@ -1,9 +1,10 @@ # ~*~ coding: utf-8 ~*~ # +from orgs.utils import set_to_root_org __all__ = [ - 'AssetsFilterMixin', 'RemoteAppFilterMixin', + 'AssetsFilterMixin', 'RemoteAppFilterMixin', 'ChangeOrgIfNeedMixin', ] @@ -100,3 +101,17 @@ class RemoteAppFilterMixin(object): queryset, key=lambda x: getattr(x, order_by), reverse=reverse ) return queryset + + +class ChangeOrgIfNeedMixin(object): + + @staticmethod + def change_org_if_need(request, kwargs): + if request.user.is_authenticated and request.user.is_superuser \ + or request.user.is_app \ + or kwargs.get('pk') is None: + set_to_root_org() + + def get(self, request, *args, **kwargs): + self.change_org_if_need(request, kwargs) + return super().get(request, *args, **kwargs) From c17d95dae0178e12c620e990dbef44c7cfc9f14c Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Thu, 20 Jun 2019 11:38:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E6=B5=8B=E8=AF=95=E7=9A=84=E6=8E=A5=E5=8F=97=E8=80=85?= =?UTF-8?q?=E4=B8=BA=E5=8F=91=E9=80=81=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/settings/api.py b/apps/settings/api.py index d399d207c..37d63bef1 100644 --- a/apps/settings/api.py +++ b/apps/settings/api.py @@ -39,7 +39,7 @@ class MailTestingAPI(APIView): subject = "Test" message = "Test smtp setting" email_from = email_from or email_host_user - send_mail(subject, message, email_from, [email_host_user]) + send_mail(subject, message, email_from, [email_from]) except Exception as e: return Response({"error": str(e)}, status=401)