Skip to content

Commit 38d4223

Browse files
authored
Merge pull request #42 from jiayuan929/fix-dependency
fix: delete the hardcoded http protocol
2 parents ca789aa + 6abcfe8 commit 38d4223

File tree

8 files changed

+13
-43
lines changed

8 files changed

+13
-43
lines changed

backend/account/accounts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ class Account(AccountSingleton):
5252
提供通用的账号功能
5353
"""
5454

55+
# 本地开发时会配置 LOGIN_DOMAIN
5556
if settings.LOGIN_DOMAIN:
56-
BK_LOGIN_URL = "http://%s/login/" % settings.LOGIN_DOMAIN
57+
BK_LOGIN_URL = f"{settings.HTTP_SCHEMA}://{settings.LOGIN_DOMAIN}/login/"
5758
else:
59+
# 线上 LOGIN_DOMAIN 为空
5860
BK_LOGIN_URL = "/login/"
5961

6062
# 蓝鲸统一登录约定的错误码, 表示用户认证成功,但用户无应用访问权限

backend/app/utils.py

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,11 @@
1717
1818
to the current version of the project delivered to anyone in the future.
1919
"""
20-
from django.conf import settings
2120
from django.contrib.auth import get_user_model
2221

23-
from common.http import http_get
24-
from common.log import logger
25-
26-
27-
def _get_users_from_login_service(bk_token):
28-
"""
29-
获取所有用户的信息
30-
"""
31-
param = {"bk_token": bk_token}
32-
if settings.LOGIN_DOMAIN:
33-
get_user_url = "http://%s/login/accounts/get_all_user/" % settings.LOGIN_DOMAIN
34-
else:
35-
get_user_url = "%s/login/accounts/get_all_user/" % settings.LOGIN_HOST
36-
37-
result, resp = http_get(get_user_url, param)
38-
resp = resp if result and resp else {}
39-
ret = resp.get("result", False) if result and resp else False
40-
# 获取用户信息失败
41-
if not ret:
42-
logger.error(u"Get user information from the request platform interface failed:%s" % resp.get("message", ""))
43-
return False, []
44-
return True, resp.get("data", [])
45-
4622

4723
def get_users(request):
48-
# 用户信息从统一登录接口获取
49-
bk_token = request.COOKIES.get(settings.BK_COOKIE_NAME, None)
50-
res, users = _get_users_from_login_service(bk_token)
51-
# 接口返回出错则直接从数据库获取
52-
if not res:
53-
# 获取所有的用户信息
54-
user_model = get_user_model()
55-
users = user_model.objects.all().values("username")
24+
# 获取所有的用户信息
25+
user_model = get_user_model()
26+
users = user_model.objects.all().values("username")
5627
return users

backend/blueking/component/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
APP_CODE = settings.APP_ID
1919
SECRET_KEY = settings.ESB_TOKEN
20-
COMPONENT_SYSTEM_HOST = "http://%s" % settings.PAAS_INNER_DOMAIN
20+
COMPONENT_SYSTEM_HOST = settings.BK_COMPONENT_API_URL
2121
except Exception:
2222
APP_CODE = ""
2323
SECRET_KEY = ""

backend/common/bk_iam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
}
7777

7878
# 线上环境走内网,开发环境配置host
79-
BK_IAM_HOST = "%s://%s" % ("http", settings.HOST_IAM_NEW)
80-
BK_PAAS_HOST = "%s://%s" % ("http", settings.PAAS_INNER_DOMAIN)
79+
BK_IAM_HOST = settings.BK_IAM_API_URL
80+
BK_PAAS_HOST = settings.BK_PAAS3_URL
8181
# bk_paas
8282
SYSTEM_ID = settings.PAAS_APP_ID
8383

backend/components/esb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _call_esb_api(http_func, url_path, data, timeout=30):
4444
"X-Bkapi-Authorization": json.dumps(common_params),
4545
}
4646

47-
url = "http://{}{}".format(settings.PAAS_INNER_DOMAIN, url_path)
47+
url = f"{settings.BK_COMPONENT_API_URL}{url_path}"
4848

4949
ok, resp_data = http_func(url, data, headers=headers)
5050

backend/conf/settings_env.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"""
2222

2323
import environ
24-
import urllib3
2524

2625
from conf.default import APP_ID, LANGUAGE_COOKIE_NAME
2726

@@ -83,8 +82,6 @@
8382
BK_PAAS3_URL = env.str("BK_PAAS3_URL", "")
8483

8584
# 兼容二进制版本的变量
86-
PAAS_INNER_DOMAIN = urllib3.util.parse_url(BK_COMPONENT_API_URL).host
87-
HOST_IAM_NEW = urllib3.util.parse_url(BK_IAM_API_URL).host
8885
BK_USER_APP_CODE = "bk_usermgr"
8986
# 用户管理访问地址
9087
BK_USER_URL = env.str("BK_USER_URL", "")

backend/poetry.lock

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

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["blueking <[email protected]>"]
66

77
[tool.poetry.dependencies]
88
python = ">=3.11,<3.12"
9-
django = "4.2.16"
9+
django = "4.2.17"
1010
whitenoise = "5.3.0"
1111
requests = "2.32.3"
1212
gunicorn = "22.0.0"

0 commit comments

Comments
 (0)