mirror of https://github.com/jumpserver/jumpserver
fix: 修复获取远程应用认证信息问题
parent
522dcb3ee9
commit
f433b0e653
|
@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from orgs.mixins.models import OrgModelMixin
|
from orgs.mixins.models import OrgModelMixin
|
||||||
from common.mixins import CommonModelMixin
|
from common.mixins import CommonModelMixin
|
||||||
from common.tree import TreeNode
|
from common.tree import TreeNode
|
||||||
|
from common.utils import is_uuid
|
||||||
from assets.models import Asset, SystemUser
|
from assets.models import Asset, SystemUser
|
||||||
|
|
||||||
from ..utils import KubernetesTree
|
from ..utils import KubernetesTree
|
||||||
|
@ -254,12 +255,12 @@ class Application(CommonModelMixin, OrgModelMixin, ApplicationTreeNodeMixin):
|
||||||
'parameters': parameters
|
'parameters': parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_remote_app_asset(self):
|
def get_remote_app_asset(self, raise_exception=True):
|
||||||
asset_id = self.attrs.get('asset')
|
asset_id = self.attrs.get('asset')
|
||||||
if not asset_id:
|
if is_uuid(asset_id):
|
||||||
|
return Asset.objects.filter(id=asset_id).first()
|
||||||
|
if raise_exception:
|
||||||
raise ValueError("Remote App not has asset attr")
|
raise ValueError("Remote App not has asset attr")
|
||||||
asset = Asset.objects.filter(id=asset_id).first()
|
|
||||||
return asset
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationUser(SystemUser):
|
class ApplicationUser(SystemUser):
|
||||||
|
|
|
@ -133,6 +133,14 @@ class AuthMixin:
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
def load_app_more_auth(self, app_id=None, username=None, user_id=None):
|
def load_app_more_auth(self, app_id=None, username=None, user_id=None):
|
||||||
|
from applications.models import Application
|
||||||
|
app = get_object_or_none(Application, pk=app_id)
|
||||||
|
if app and app.category_remote_app:
|
||||||
|
# Remote app
|
||||||
|
self._load_remoteapp_more_auth(app, username, user_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Other app
|
||||||
self._clean_auth_info_if_manual_login_mode()
|
self._clean_auth_info_if_manual_login_mode()
|
||||||
# 加载临时认证信息
|
# 加载临时认证信息
|
||||||
if self.login_mode == self.LOGIN_MANUAL:
|
if self.login_mode == self.LOGIN_MANUAL:
|
||||||
|
@ -148,6 +156,11 @@ class AuthMixin:
|
||||||
_username = username
|
_username = username
|
||||||
self.username = _username
|
self.username = _username
|
||||||
|
|
||||||
|
def _load_remoteapp_more_auth(self, app, username, user_id):
|
||||||
|
asset = app.get_remote_app_asset(raise_exception=False)
|
||||||
|
if asset:
|
||||||
|
self.load_asset_more_auth(asset_id=asset.id, username=username, user_id=user_id)
|
||||||
|
|
||||||
def load_asset_special_auth(self, asset, username=''):
|
def load_asset_special_auth(self, asset, username=''):
|
||||||
"""
|
"""
|
||||||
AuthBook 的数据状态
|
AuthBook 的数据状态
|
||||||
|
|
Loading…
Reference in New Issue