Compare commits

...

21 Commits

Author SHA1 Message Date
fit2bot
f4c13df19e feat: Update v3.6.1 2023-08-18 21:01:34 +08:00
老广
180cf354ad Merge pull request #11360 from jumpserver/pr@v3.6@perf_login_csrf
perf: 修改 csrf 登录时判断
2023-08-18 20:44:47 +08:00
ibuler
89a5c970e4 perf: 修改 csrf 登录时判断 2023-08-18 12:37:32 +00:00
老广
1d25cad449 Merge pull request #11359 from jumpserver/pr@v3.6@perf_csrf_token_error
perf: 修改 csrf token 提示
2023-08-18 18:46:02 +08:00
ibuler
c3b0798311 perf: 修改 csrf token 提示 2023-08-18 10:44:23 +00:00
ibuler
ff851b4672 perf: 去掉 migrate 提示 2023-08-18 15:17:20 +05:00
老广
2bcdcce2d3 Merge pull request #11352 from jumpserver/pr@v3.6@perf_login_info
perf: 优化登录页面提示判断,可能没有端口
2023-08-18 18:11:40 +08:00
ibuler
f5ac941eb3 perf: 优化登录页面提示判断,可能没有端口
perf: 修改 login 检测
2023-08-18 09:59:53 +00:00
老广
efcbfe63f9 Merge pull request #11350 from jumpserver/pr@v3.6@perf_info
perf: 修改说明
2023-08-18 17:01:15 +08:00
ibuler
41a2e00406 perf: 修改说明 2023-08-18 08:59:40 +00:00
老广
738b9efe11 Merge pull request #11345 from jumpserver/pr@v3.6@fix_sessionshare
fix: 修复创建会话分享不填写用户报错的问题
2023-08-18 16:52:24 +08:00
ibuler
119c7a8634 perf: 优化登录提示 2023-08-18 13:51:51 +05:00
Bai
77e43c1c5c fix: 修复创建会话分享不填写用户报错的问题 2023-08-18 08:46:14 +00:00
老广
4d0231a9ad Merge pull request #11344 from jumpserver/pr@v3.6@allow_hosts_to_all
perf: 修改 allowed hosts
2023-08-18 16:17:00 +08:00
ibuler
4562f1fbe8 perf: 修改 allowed hosts 2023-08-18 08:16:04 +00:00
Bai
4be70ff3da fix: 修复资产树子节点创建后没有获取到的问题 2023-08-18 13:03:34 +05:00
老广
1a742d65f6 Merge pull request #11338 from jumpserver/pr@v3.6@perf_depends
perf: 优化依赖
2023-08-18 15:26:48 +08:00
ibuler
ba83b64d87 perf: 优化依赖 2023-08-18 15:23:01 +08:00
feng
f46c9f56e8 fix: 修复密钥校验ansible不支持{% 2023-08-17 16:16:15 +05:00
老广
626ec8f25d Merge pull request #11325 from jumpserver/pr@v3.6@perf_django_ca_version
perf: 修改 django cas version
2023-08-17 17:50:15 +08:00
ibuler
526c7de598 perf: 修改 django cas version 2023-08-17 09:48:19 +00:00
15 changed files with 102 additions and 46 deletions

1
GITSHA Normal file
View File

@@ -0,0 +1 @@
180cf354ad205c69fbb915eb49d906ccc31ed118

View File

@@ -113,7 +113,7 @@ class Migration(migrations.Migration):
('comment', models.TextField(blank=True, default='', verbose_name='Comment')),
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
('old_secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Old secret')),
('new_secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')),
('new_secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='New secret')),
('date_started', models.DateTimeField(blank=True, null=True, verbose_name='Date started')),
('date_finished', models.DateTimeField(blank=True, null=True, verbose_name='Date finished')),
('status', models.CharField(default='pending', max_length=16)),

View File

@@ -39,6 +39,8 @@ def validate_password_for_ansible(password):
# Ansible 推送的时候不支持
if '{{' in password:
raise serializers.ValidationError(_('Password can not contains `{{` '))
if '{%' in password:
raise serializers.ValidationError(_('Password can not contains `{%` '))
# Ansible Windows 推送的时候不支持
if "'" in password:
raise serializers.ValidationError(_("Password can not contains `'` "))

View File

@@ -42,7 +42,7 @@ class SerializeToTreeNodeMixin:
'name': _name(node),
'title': _name(node),
'pId': node.parent_key,
'isParent': node.assets_amount > 0,
'isParent': True,
'open': _open(node),
'meta': {
'data': {

View File

@@ -223,10 +223,22 @@
height: 13px;
cursor: pointer;
}
.error-info {
font-size: 16px;
text-align: center;
}
</style>
</head>
<body>
{% if error_origin %}
<div class='alert alert-danger error-info'>
配置文件存在问题无法完成登录请联系管理员解决或查看最新更新说明 <br/>
Configuration file has problems and cannot be logged in. Please contact the administrator <br/>
- {{ error_origin }} -
</div>
{% endif %}
<div class="login-content extra-fields-{{ extra_fields_count }}">
<div class="right-image-box">
<a href="{% if not XPACK_ENABLED %}https://github.com/jumpserver/jumpserver.git{% endif %}">

View File

@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import datetime
import os
from typing import Callable
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.auth import BACKEND_SESSION_KEY
@@ -40,6 +41,7 @@ __all__ = [
class UserLoginContextMixin:
get_user_mfa_context: Callable
request: HttpRequest
error_origin: str
def get_support_auth_methods(self):
auth_methods = [
@@ -134,8 +136,27 @@ class UserLoginContextMixin:
count += 1
return count
def set_csrf_error_if_need(self, context):
if not self.request.GET.get('csrf_failure'):
return context
http_origin = self.request.META.get('HTTP_ORIGIN')
http_referer = self.request.META.get('HTTP_REFERER')
http_origin = http_origin or http_referer
if not http_origin:
return context
try:
origin = urlparse(http_origin)
context['error_origin'] = str(origin.netloc)
except ValueError:
pass
return context
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
self.set_csrf_error_if_need(context)
context.update({
'demo_mode': os.environ.get("DEMO_MODE"),
'auth_methods': self.get_support_auth_methods(),

View File

@@ -88,11 +88,12 @@ if DEBUG:
DEBUG_HOST_PORTS = ['{}:{}'.format(host, port) for host in DEBUG_HOSTS for port in DEBUG_PORT]
ALLOWED_DOMAINS.extend(DEBUG_HOST_PORTS)
ALLOWED_HOSTS = list(set(['.' + host.split(':')[0] for host in ALLOWED_DOMAINS]))
print("ALLOWED_HOSTS: ", )
for host in ALLOWED_HOSTS:
for host in ALLOWED_DOMAINS:
print(' - ' + host.lstrip('.'))
ALLOWED_HOSTS = ['*']
# https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS
CSRF_TRUSTED_ORIGINS = []
for host_port in ALLOWED_DOMAINS:
@@ -106,6 +107,7 @@ for host_port in ALLOWED_DOMAINS:
continue
CSRF_TRUSTED_ORIGINS.append('{}://*.{}'.format(schema, origin))
CSRF_FAILURE_VIEW = 'jumpserver.views.other.csrf_failure'
# print("CSRF_TRUSTED_ORIGINS: ")
# for origin in CSRF_TRUSTED_ORIGINS:
# print(' - ' + origin)

View File

@@ -88,3 +88,9 @@ class KokoView(View):
class ResourceDownload(TemplateView):
template_name = 'resource_download.html'
def csrf_failure(request, reason=""):
from django.shortcuts import reverse
login_url = reverse('authentication:login') + '?csrf_failure=1&admin=1'
return redirect(login_url)

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:810d46e14e09a2309a8d898bc391f33082bfc5c164dec246bd95cea8436e33ee
size 154540
oid sha256:f87b3d05a2f665ef21a4876b9af8ba651936220b35633d1dc6a93941000bd253
size 154676

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-17 15:30+0800\n"
"POT-Creation-Date: 2023-08-17 18:24+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -857,15 +857,19 @@ msgstr "アカウント接続のテスト"
msgid "Password can not contains `{{` "
msgstr "パスワードには '{{' を含まない"
#: accounts/utils.py:44
#: accounts/utils.py:43
msgid "Password can not contains `{%` "
msgstr "パスワードには '{%' を含まない"
#: accounts/utils.py:46
msgid "Password can not contains `'` "
msgstr "パスワードには `'` を含まない"
#: accounts/utils.py:46
#: accounts/utils.py:48
msgid "Password can not contains `\"` "
msgstr "パスワードには `\"` を含まない"
#: accounts/utils.py:52
#: accounts/utils.py:54
msgid "private key invalid or passphrase error"
msgstr "秘密鍵が無効またはpassphraseエラー"
@@ -1032,7 +1036,7 @@ msgid "None of the reviewers belong to Organization `{}`"
msgstr "いずれのレビューアも組織 '{}' に属していません"
#: acls/serializers/rules/rules.py:20
#: xpack/plugins/cloud/serializers/task.py:133
#: xpack/plugins/cloud/serializers/task.py:137
msgid "IP address invalid: `{}`"
msgstr "IPアドレスが無効: '{}'"
@@ -7696,7 +7700,7 @@ msgstr "クラウドアカウント"
msgid "Test cloud account"
msgstr "クラウドアカウントのテスト"
#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers/task.py:147
#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers/task.py:151
msgid "Regions"
msgstr "リージョン"
@@ -7705,17 +7709,17 @@ msgid "Hostname strategy"
msgstr "ホスト名戦略"
#: xpack/plugins/cloud/models.py:100
#: xpack/plugins/cloud/serializers/task.py:150
#: xpack/plugins/cloud/serializers/task.py:154
msgid "IP network segment group"
msgstr "IPネットワークセグメントグループ"
#: xpack/plugins/cloud/models.py:103
#: xpack/plugins/cloud/serializers/task.py:155
#: xpack/plugins/cloud/serializers/task.py:159
msgid "Sync IP type"
msgstr "同期IPタイプ"
#: xpack/plugins/cloud/models.py:106
#: xpack/plugins/cloud/serializers/task.py:173
#: xpack/plugins/cloud/serializers/task.py:177
msgid "Always update"
msgstr "常に更新"
@@ -7808,7 +7812,7 @@ msgstr "ルール一致"
msgid "Rule value"
msgstr "ルール値"
#: xpack/plugins/cloud/models.py:317
#: xpack/plugins/cloud/models.py:317 xpack/plugins/cloud/serializers/task.py:70
msgid "Strategy rule"
msgstr "戦略ルール"
@@ -7820,7 +7824,7 @@ msgstr "アクション属性"
msgid "Action value"
msgstr "アクション値"
#: xpack/plugins/cloud/models.py:341
#: xpack/plugins/cloud/models.py:341 xpack/plugins/cloud/serializers/task.py:73
msgid "Strategy action"
msgstr "戦略アクション"
@@ -8108,7 +8112,7 @@ msgstr "テストタイムアウト"
msgid "Project"
msgstr "project"
#: xpack/plugins/cloud/serializers/task.py:139
#: xpack/plugins/cloud/serializers/task.py:143
msgid ""
"Only instances matching the IP range will be synced. <br>If the instance "
"contains multiple IP addresses, the first IP address that matches will be "
@@ -8122,11 +8126,11 @@ msgstr ""
"ドレスをランダムに一致させることを意味します。 <br> 例: "
"192.168.1.0/24,10.1.1.1-10.1.1.20。"
#: xpack/plugins/cloud/serializers/task.py:145
#: xpack/plugins/cloud/serializers/task.py:149
msgid "History count"
msgstr "実行回数"
#: xpack/plugins/cloud/serializers/task.py:146
#: xpack/plugins/cloud/serializers/task.py:150
msgid "Instance count"
msgstr "インスタンス数"

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:da4f312ed86d27fa8b6bde8da3bc70b0f32fe40811ee855f9fe81d89a68a646f
size 126402
oid sha256:f2f7fa427404ca2b2f5651cb1be3e84876dad9d72f14e488321a2dc84d4f4051
size 126472

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-17 15:30+0800\n"
"POT-Creation-Date: 2023-08-17 18:24+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n"
@@ -857,15 +857,19 @@ msgstr "测试账号可连接性"
msgid "Password can not contains `{{` "
msgstr "密码不能包含 `{{` 字符"
#: accounts/utils.py:44
#: accounts/utils.py:43
msgid "Password can not contains `{%` "
msgstr "密码不能包含 `{%` 字符"
#: accounts/utils.py:46
msgid "Password can not contains `'` "
msgstr "密码不能包含 `'` 字符"
#: accounts/utils.py:46
#: accounts/utils.py:48
msgid "Password can not contains `\"` "
msgstr "密码不能包含 `\"` 字符"
#: accounts/utils.py:52
#: accounts/utils.py:54
msgid "private key invalid or passphrase error"
msgstr "密钥不合法或密钥密码错误"
@@ -1031,7 +1035,7 @@ msgid "None of the reviewers belong to Organization `{}`"
msgstr "所有复核人都不属于组织 `{}`"
#: acls/serializers/rules/rules.py:20
#: xpack/plugins/cloud/serializers/task.py:133
#: xpack/plugins/cloud/serializers/task.py:137
msgid "IP address invalid: `{}`"
msgstr "IP 地址无效: `{}`"
@@ -7588,7 +7592,7 @@ msgstr "云账号"
msgid "Test cloud account"
msgstr "测试云账号"
#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers/task.py:147
#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers/task.py:151
msgid "Regions"
msgstr "地域"
@@ -7597,17 +7601,17 @@ msgid "Hostname strategy"
msgstr "主机名策略"
#: xpack/plugins/cloud/models.py:100
#: xpack/plugins/cloud/serializers/task.py:150
#: xpack/plugins/cloud/serializers/task.py:154
msgid "IP network segment group"
msgstr "IP网段组"
#: xpack/plugins/cloud/models.py:103
#: xpack/plugins/cloud/serializers/task.py:155
#: xpack/plugins/cloud/serializers/task.py:159
msgid "Sync IP type"
msgstr "同步IP类型"
#: xpack/plugins/cloud/models.py:106
#: xpack/plugins/cloud/serializers/task.py:173
#: xpack/plugins/cloud/serializers/task.py:177
msgid "Always update"
msgstr "总是更新"
@@ -7700,7 +7704,7 @@ msgstr "规则匹配"
msgid "Rule value"
msgstr "规则值"
#: xpack/plugins/cloud/models.py:317
#: xpack/plugins/cloud/models.py:317 xpack/plugins/cloud/serializers/task.py:70
msgid "Strategy rule"
msgstr "策略规则"
@@ -7712,7 +7716,7 @@ msgstr "动作属性"
msgid "Action value"
msgstr "动作值"
#: xpack/plugins/cloud/models.py:341
#: xpack/plugins/cloud/models.py:341 xpack/plugins/cloud/serializers/task.py:73
msgid "Strategy action"
msgstr "策略动作"
@@ -7999,7 +8003,7 @@ msgstr "测试超时时间"
msgid "Project"
msgstr "project"
#: xpack/plugins/cloud/serializers/task.py:139
#: xpack/plugins/cloud/serializers/task.py:143
msgid ""
"Only instances matching the IP range will be synced. <br>If the instance "
"contains multiple IP addresses, the first IP address that matches will be "
@@ -8011,11 +8015,11 @@ msgstr ""
"到的 IP 地址将被用作创建的资产的 IP。<br>默认值 * 表示同步所有实例和随机匹配 "
"IP 地址。<br> 例如: 192.168.1.0/24,10.1.1.1-10.1.1.20。"
#: xpack/plugins/cloud/serializers/task.py:145
#: xpack/plugins/cloud/serializers/task.py:149
msgid "History count"
msgstr "执行次数"
#: xpack/plugins/cloud/serializers/task.py:146
#: xpack/plugins/cloud/serializers/task.py:150
msgid "Instance count"
msgstr "实例个数"

View File

@@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property
from common.db.models import JMSBaseModel
from common.utils import is_uuid
from orgs.mixins.models import OrgModelMixin
from orgs.utils import tmp_to_root_org
from users.models import User
@@ -62,6 +63,9 @@ class SessionSharing(JMSBaseModel, OrgModelMixin):
@cached_property
def users_queryset(self):
user_ids = self.users.split(',')
user_ids = [user_id for user_id in user_ids if is_uuid(user_id)]
if not user_ids:
return User.objects.none()
return User.objects.filter(id__in=user_ids)
@property

12
poetry.lock generated
View File

@@ -1348,13 +1348,13 @@ reference = "tsinghua"
[[package]]
name = "click"
version = "8.1.6"
version = "8.1.7"
description = "Composable command line interface toolkit"
optional = false
python-versions = ">=3.7"
files = [
{file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"},
{file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"},
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
{file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"},
]
[package.dependencies]
@@ -1824,7 +1824,7 @@ description = ""
optional = false
python-versions = ">=3.7"
files = [
{file = "django-cas-ng-4.3.1.zip", hash = "sha256:aeea96ad7958e3cb40d9bb5ef6a1add66f720835dfe87cc1dfe163f92d084690"},
{file = "django-cas-ng-4.3.2.zip", hash = "sha256:3539eae7ca857017cefa962782c99cbd35cc15ea741655b10c3417fa7e86807a"},
]
[package.dependencies]
@@ -1833,7 +1833,7 @@ python-cas = ">=1.6.0"
[package.source]
type = "url"
url = "https://github.com/ibuler/django-cas-ng/releases/download/v4.3.1/django-cas-ng-4.3.1.zip"
url = "https://github.com/ibuler/django-cas-ng/releases/download/v4.3.2/django-cas-ng-4.3.2.zip"
[[package]]
name = "django-celery-beat"
@@ -7223,4 +7223,4 @@ reference = "tsinghua"
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "0bc2878f163c8b2f48d1103d96314c56f722f10d8f8adf6dfaba0452e6eac368"
content-hash = "121cb018467440ab938aa169dcb8de096018855f0034f1cbc980d484ede3c8f1"

View File

@@ -100,7 +100,6 @@ openapi-codec = "1.3.2"
pillow = "10.0.0"
pytz = "2023.3"
django-proxy = "1.2.2"
channels-redis = "4.1.0"
python-daemon = "3.0.1"
eventlet = "0.33.3"
greenlet = "2.0.2"
@@ -114,7 +113,7 @@ websockets = "11.0.3"
python-ldap = "3.4.3"
ldap3 = "2.9.1"
django-radius = { url = "https://github.com/ibuler/django-radius/archive/refs/tags/1.5.0.zip" }
django-cas-ng = { url = "https://github.com/ibuler/django-cas-ng/releases/download/v4.3.1/django-cas-ng-4.3.1.zip" }
django-cas-ng = { url = "https://github.com/ibuler/django-cas-ng/releases/download/v4.3.2/django-cas-ng-4.3.2.zip" }
python-cas = "1.6.0"
django-auth-ldap = "4.4.0"
boto3 = "1.28.9"
@@ -137,10 +136,11 @@ hvac = "1.1.1"
pyhcl = "0.4.4"
ipy = "1.1"
netifaces = "^0.11.0"
[tool.poetry.group.dev.dependencies]
channels-redis = "4.1.0"
daphne = "4.0.0"
channels = "^4.0.0"
[tool.poetry.group.dev.dependencies]
channels-redis = "^4.1.0"
[tool.poetry.group.xpack.dependencies]