Skip to content

Commit

Permalink
refactor: minor
Browse files Browse the repository at this point in the history
N
  • Loading branch information
jamesgetx committed Dec 20, 2024
1 parent b2e707e commit 516dae5
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sdks/bkpaas-auth/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 版本历史

## 3.0.1
## 3.1.0
- feat: UniversalAuthBackend 支持获取用户租户身份信息

## 3.0.0
Expand Down
4 changes: 2 additions & 2 deletions sdks/bkpaas-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BKAUTH_ENABLE_MULTI_TENANT_MODE = True
BKAUTH_BACKEND_TYPE = "bk_token" # 只能选择:bk_token

# 验证用户信息的网关 API(租户版本)
#https://{网关域名}/api/bk-login/prod/login/api/v3/open/bk-tokens/userinfo/
#BK_API_URL_TMPL.format(api_name="bk-login") + "/prod/login/api/v3/open/bk-tokens/userinfo/"
BKAUTH_USER_INFO_APIGW_URL = ""

# [可选]`BKAUTH_DEFAULT_PROVIDER_TYPE` 的值用于 JWT 校验时获取默认的用户认证类型。
Expand Down Expand Up @@ -147,7 +147,7 @@ class YourDjangoAuthUserCompatibleBackend(DjangoAuthUserCompatibleBackend):
return db_user
```

> 说明: 启用多租户模式后, user 会增加 tenant_id 字段,可以通过 `request.user.tenant_id` 获取租户 ID
> 说明: 启用多租户模式后, user 会增加 tenant_id 和 display_name 两个字段,可以通过 `request.user.tenant_id` 获取租户 ID, 通过 `request.user.display_name` 获取用户展示名。
#### [apigw-manager](../apigw-manager) 集成
该 SDK 可以和 apigw-manager 集成,完成网关 JWT 的校验,在 settings 中配置:
Expand Down
2 changes: 1 addition & 1 deletion sdks/bkpaas-auth/bkpaas_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__version__ = "3.0.1"
__version__ = "3.1.0"


def get_user_by_user_id(user_id: str, username_only: bool = True):
Expand Down
4 changes: 2 additions & 2 deletions sdks/bkpaas-auth/bkpaas_auth/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import requests

from bkpaas_auth.conf import bkauth_settings
from bkpaas_auth.core.exceptions import HttpRequestError, ResponseError
from bkpaas_auth.core.exceptions import HttpRequestError, ServiceError
from bkpaas_auth.utils import scrub_data

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -69,7 +69,7 @@ def resp_to_json(resp: requests.Response) -> Union[dict, list]:
resp.status_code,
resp.text,
)
raise ResponseError("parse response error")
raise ServiceError("parse json response error")


def http_get(url: str, **kwargs) -> requests.Response:
Expand Down
1 change: 1 addition & 0 deletions sdks/bkpaas-auth/bkpaas_auth/core/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _request_apigw(**credentials) -> UserAccount:
headers={
'blueking-language': get_language(),
"X-Bkapi-Authorization": json.dumps(get_app_credentials()),
"X-Bk-Tenant-Id": "default",
},
params=credentials,
)
Expand Down
2 changes: 1 addition & 1 deletion sdks/bkpaas-auth/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bkpaas-auth"
version = "3.0.1"
version = "3.1.0"
description = "User authentication django app for blueking internal projects"
readme = "README.md"
authors = ["blueking <blueking@tencent.com>"]
Expand Down
2 changes: 1 addition & 1 deletion sdks/bkpaas-auth/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
setup(
long_description=readme,
name='bkpaas-auth',
version='3.0.1',
version='3.1.0',
description='User authentication django app for blueking internal projects',
python_requires='<4.0,>=3.8',
author='blueking',
Expand Down

0 comments on commit 516dae5

Please sign in to comment.