Skip to content

Commit bac660f

Browse files
authored
Merge pull request #49 from jiayuan929/tenant-623
feat:依赖组件升级&支持 TLS
2 parents 85f1dc0 + c225dce commit bac660f

File tree

8 files changed

+887
-169
lines changed

8 files changed

+887
-169
lines changed

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3.11.10-slim-bullseye
22
USER root
33

4-
RUN apt-get update && apt-get install -y wget file gcc curl procps -y
4+
RUN apt-get update && apt-get install -y file gcc curl procps -y
55

66
RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.cloud.tencent.com/pypi/simple/\nextra-index-url = https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/' > ~/.pip/pip.conf
77

backend/apigw/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_user_department_ids(self, username: str) -> list:
115115
for d in data:
116116
department_ids.add(d["id"])
117117

118-
if d.get("family"):
118+
if d.get("ancestors"):
119119
for f in d.get("ancestors"):
120120
department_ids.add(f["id"])
121121

backend/app/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ class App(models.Model):
190190
verbose_name="应用租户模式",
191191
max_length=16,
192192
default=AppTenantMode.GLOBAL,
193-
help_text="应用在租户层面的可用范围,可选值:全租户、指定租户",
193+
help_text="应用在租户层面的可用范围,可选值:全租户(global)、单租户(single)",
194194
)
195195
app_tenant_id = models.CharField(
196196
verbose_name="应用租户 ID",
197197
max_length=32,
198198
default="",
199199
help_text="应用对哪个租户的用户可用,当应用租户模式为全租户时,本字段值为空",
200+
blank=True,
200201
)
201202
tenant_id = models.CharField(
202203
verbose_name="租户 ID",

backend/conf/settings_env.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@
4141
}
4242
}
4343

44+
# 数据库 ssl 配置
45+
BK_PAAS_DATABASE_TLS_ENABLED = env.bool("BK_PAAS_DATABASE_TLS_ENABLED", False)
46+
if BK_PAAS_DATABASE_TLS_ENABLED:
47+
default_ssl_options = {
48+
"ca": env.str("BK_PAAS_DATABASE_TLS_CERT_CA_FILE", ""),
49+
}
50+
# mTLS
51+
default_cert_file = env.str("BK_PAAS_DATABASE_TLS_CERT_FILE", "")
52+
default_key_file = env.str("BK_PAAS_DATABASE_TLS_CERT_KEY_FILE", "")
53+
if default_cert_file and default_key_file:
54+
default_ssl_options["cert"] = default_cert_file
55+
default_ssl_options["key"] = default_key_file
56+
# 跳过主机名/IP 验证,会降低安全性,正式环境不能开启
57+
check_hostname = env.bool("BK_PAAS_DATABASE_TLS_CHECK_HOSTNAME", True)
58+
default_ssl_options["check_hostname"] = check_hostname
59+
60+
if "OPTIONS" not in DATABASES["default"]:
61+
DATABASES["default"]["OPTIONS"] = {}
62+
DATABASES["default"]["OPTIONS"]["ssl"] = default_ssl_options
63+
4464
# 是否展示蓝鲸产品版本信息
4565
IS_BK_SUITE_ENABLED = env.bool("IS_BK_SUITE_ENABLED", False)
4666
if IS_BK_SUITE_ENABLED:

backend/desktop/manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ def get_user_desktop_app_info(self, user, tenant_id):
675675
# 开启多租户则过滤出:全租户应用 + 本租户的应用
676676
if settings.ENABLE_MULTI_TENANT_MODE:
677677
user_app_queryset = user_app_queryset.filter(
678-
Q(app__app_tenant_mode=AppTenantMode.GLOBAL)
678+
Q(desk_app_type=1)
679+
| Q(app__app_tenant_mode=AppTenantMode.GLOBAL)
679680
| Q(app__app_tenant_mode=AppTenantMode.SINGLE, app__app_tenant_id=tenant_id)
680681
)
681682
user_app_by_desk = user_app_queryset.values(

backend/poetry.lock

Lines changed: 856 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ name = "蓝鲸桌面"
33
version = "0.1.0"
44
description = "Tencent Blueking console"
55
authors = ["blueking <[email protected]>"]
6+
package-mode = false
67

78
[tool.poetry.dependencies]
89
python = ">=3.11,<3.12"
9-
django = "4.2.17"
10+
django = "4.2.23"
1011
whitenoise = "5.3.0"
1112
requests = "2.32.3"
12-
gunicorn = "22.0.0"
13+
gunicorn = "23.0.0"
1314
pymysql = "1.1.1"
1415
gevent = "24.2.1"
1516
pytz = "2024.2"
@@ -22,6 +23,7 @@ future = "1.0.0"
2223
urllib3 = "2.2.2"
2324
Pillow = "10.3.0"
2425
bk-notice-sdk = ">=1.3.2"
26+
setuptools = ">=80.9.0"
2527

2628

2729
[tool.poetry.dev-dependencies]

backend/templates/desktop/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<div class="startmenu-selfinfo"></div>
160160
<ul class="startmenu">
161161
<li>
162-
<a><span class="startmenu-username">{{request.user.chname}}</span></a>
162+
<a onclick="BLUEKING.api.open_app_by_desk('bk_usermgr')" style="display: flex;"><span title="{{request.user.chname}}" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="startmenu-username">{{request.user.chname}}</span></a>
163163
</li>
164164
<li><a href="{{BK_DOCS_URL_PREFIX}}" target="blank" class="">{% trans '文档中心' %}</a></li>
165165
<li><a href="javascript:;" class="about">{% trans '蓝鲸官网' %}</a></li>

0 commit comments

Comments
 (0)