Skip to content

Commit 3907320

Browse files
author
bennychen
committed
fix: 修复获取用户扩展属性异常的问题
1 parent 9a20f8d commit 3907320

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py

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

7979
# 用户认证
8080
AUTHENTICATION_BACKENDS += (
81-
"apigw_manager.apigw.authentication.UserModelBackend",
81+
"bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend",
8282
)
8383

8484
# 所有环境的日志级别可以在这里配置

runtime/bk-plugin-runtime/bk_plugin_runtime/packages/apigw/__init__.py

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
4+
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://opensource.org/licenses/MIT
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
"""
12+
13+
from apigw_manager.apigw.authentication import UserModelBackend
14+
from django.contrib.auth import get_user_model
15+
16+
USER_MODEL = get_user_model()
17+
18+
19+
class APIGWUserModelBackend(UserModelBackend):
20+
"""
21+
APIGW User Backend
22+
"""
23+
24+
def make_user(self, username: str):
25+
if not username:
26+
return None
27+
user, _ = USER_MODEL.objects.get_or_create(username=username)
28+
return user
29+
30+
def authenticate(self, request, gateway_name, bk_username, verified, **credentials):
31+
return self.make_user(bk_username)

0 commit comments

Comments
 (0)