Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
133a2e47
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
133a2e47
编写于
11月 13, 2020
作者:
baltery
提交者:
Jiangjie.Bai
11月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(assets): 修复动态系统用户推送的bug
上级
b4b9149d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
4 deletion
+13
-4
apps/assets/models/base.py
apps/assets/models/base.py
+4
-2
apps/assets/models/user.py
apps/assets/models/user.py
+5
-0
apps/assets/tasks/push_system_user.py
apps/assets/tasks/push_system_user.py
+4
-2
未找到文件。
apps/assets/models/base.py
浏览文件 @
133a2e47
...
...
@@ -158,9 +158,11 @@ class AuthMixin:
if
update_fields
:
self
.
save
(
update_fields
=
update_fields
)
def
has_special_auth
(
self
,
asset
=
None
):
def
has_special_auth
(
self
,
asset
=
None
,
username
=
None
):
from
.authbook
import
AuthBook
queryset
=
AuthBook
.
objects
.
filter
(
username
=
self
.
username
)
if
username
is
None
:
username
=
self
.
username
queryset
=
AuthBook
.
objects
.
filter
(
username
=
username
)
if
asset
:
queryset
=
queryset
.
filter
(
asset
=
asset
)
return
queryset
.
exists
()
...
...
apps/assets/models/user.py
浏览文件 @
133a2e47
...
...
@@ -165,6 +165,11 @@ class SystemUser(BaseUser):
def
is_need_test_asset_connective
(
self
):
return
self
.
protocol
not
in
self
.
application_category_protocols
def
has_special_auth
(
self
,
asset
=
None
,
username
=
None
):
if
username
is
None
and
self
.
username_same_with_user
:
raise
TypeError
(
'System user is dynamic, username should be pass'
)
return
super
().
has_special_auth
(
asset
=
asset
,
username
=
username
)
@
property
def
can_perm_to_asset
(
self
):
return
self
.
protocol
not
in
self
.
application_category_protocols
...
...
apps/assets/tasks/push_system_user.py
浏览文件 @
133a2e47
...
...
@@ -139,6 +139,7 @@ def get_push_windows_system_user_tasks(system_user, username=None):
tasks
=
[]
if
not
password
:
logger
.
error
(
"Error: no password found"
)
return
tasks
task
=
{
'name'
:
'Add user {}'
.
format
(
username
),
...
...
@@ -214,14 +215,15 @@ def push_system_user_util(system_user, assets, task_name, username=None):
print
(
_
(
"Start push system user for platform: [{}]"
).
format
(
platform
))
print
(
_
(
"Hosts count: {}"
).
format
(
len
(
_hosts
)))
if
not
system_user
.
has_special_auth
():
# 如果没有特殊密码设置,就不需要单独推送某台机器了
if
not
system_user
.
has_special_auth
(
username
=
username
):
logger
.
debug
(
"System user not has special auth"
)
tasks
=
get_push_system_user_tasks
(
system_user
,
platform
,
username
=
username
)
run_task
(
tasks
,
_hosts
)
continue
for
_host
in
_hosts
:
system_user
.
load_asset_special_auth
(
_host
)
system_user
.
load_asset_special_auth
(
_host
,
username
=
username
)
tasks
=
get_push_system_user_tasks
(
system_user
,
platform
,
username
=
username
)
run_task
(
tasks
,
[
_host
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录