Skip to content

Commit

Permalink
Merge pull request #106 from jamesgetx/sg-auth1
Browse files Browse the repository at this point in the history
feat: tokenRequestBackend.request_username support i18n
  • Loading branch information
jamesgetx authored Jul 25, 2023
2 parents c6fc613 + 685eb85 commit d2dd49a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions sdks/bkpaas-auth/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 版本历史

## 2.0.6
- TokenRequestBackend.request_username 支持国际化

## 2.0.5
- TokenRequestBackend 处理蓝鲸统一登录的错误状态码 code=1302403
- CookieLoginMiddleware 根据错误状态码 code=1302403, 限制用户的访问权限
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__ = "2.0.5"
__version__ = "2.0.6"


def get_user_by_user_id(user_id: str, username_only: bool = True):
Expand Down
12 changes: 8 additions & 4 deletions sdks/bkpaas-auth/bkpaas_auth/core/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import logging

from django.utils.timezone import now
from django.utils.translation import get_language

from bkpaas_auth.conf import bkauth_settings
from bkpaas_auth.core.constants import ProviderType, ACCESS_PERMISSION_DENIED_CODE
from bkpaas_auth.core.exceptions import InvalidTokenCredentialsError, ServiceError, AccessPermissionDenied
from bkpaas_auth.core.constants import ACCESS_PERMISSION_DENIED_CODE, ProviderType
from bkpaas_auth.core.exceptions import AccessPermissionDenied, InvalidTokenCredentialsError, ServiceError
from bkpaas_auth.core.http import http_get
from bkpaas_auth.core.user_info import BkUserInfo, RtxUserInfo, UserInfo
from bkpaas_auth.core.services import get_app_credentials
from bkpaas_auth.core.user_info import BkUserInfo, RtxUserInfo, UserInfo
from bkpaas_auth.models import User

logger = logging.getLogger(__name__)
Expand All @@ -29,7 +30,10 @@ class TokenRequestBackend(AbstractRequestBackend):
def request_username(self, **credentials):
"""Get username through credentials"""
is_success, resp = http_get(
bkauth_settings.USER_COOKIE_VERIFY_URL, params=dict(credentials, **get_app_credentials()), timeout=10
bkauth_settings.USER_COOKIE_VERIFY_URL,
params=dict(credentials, **get_app_credentials()),
timeout=10,
headers={'blueking-language': get_language()},
)
if not is_success:
raise ServiceError('unable to fetch token services')
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 = "2.0.5"
version = "2.0.6"
description = "User authentication django app for blueking internal projects"
license = "Apach License 2.0"
readme = "README.md"
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='2.0.5',
version='2.0.6',
description='User authentication django app for blueking internal projects',
python_requires='<4.0,>=3.6',
author='blueking',
Expand Down

0 comments on commit d2dd49a

Please sign in to comment.