Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
35d9be5c
Commit
35d9be5c
authored
Jan 30, 2015
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect.py
parent
c1686d52
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
445 deletions
+9
-445
connect.py
connect.py
+5
-10
views.py
jperm/views.py
+4
-82
perm_group_edit.html
templates/jperm/perm_group_edit.html
+0
-152
perm_list2.htl.html
templates/jperm/perm_list2.htl.html
+0
-0
perm_user_edit.html
templates/jperm/perm_user_edit.html
+0
-139
perm_user_show.html
templates/jperm/perm_user_show.html
+0
-62
No files found.
connect.py
View file @
35d9be5c
...
...
@@ -25,6 +25,7 @@ django.setup()
from
juser.models
import
User
from
jasset.models
import
Asset
from
jlog.models
import
Log
from
jperm.views
import
perm_user_asset
try
:
import
termios
...
...
@@ -207,14 +208,9 @@ def posix_shell(chan, username, host):
def
get_user_host
(
username
):
"""Get the hosts of under the user control."""
hosts_attr
=
{}
try
:
user
=
User
.
objects
.
get
(
username
=
username
)
except
ObjectDoesNotExist
:
raise
ServerError
(
"Username
\033
[1;31m
%
s
\033
[0m doesn't exist on Jumpserver."
%
username
)
else
:
perm_all
=
user
.
permission_set
.
all
()
for
perm
in
perm_all
:
hosts_attr
[
perm
.
asset
.
ip
]
=
[
perm
.
asset
.
id
,
perm
.
asset
.
comment
]
asset_all
=
perm_user_asset
(
username
=
username
)
for
asset
in
asset_all
:
hosts_attr
[
asset
.
ip
]
=
[
asset
.
id
,
asset
.
comment
]
return
hosts_attr
...
...
@@ -234,7 +230,6 @@ def get_connect_item(username, ip):
login_type_dict
=
{
'L'
:
user
.
ldap_pwd
,
'S'
:
user
.
ssh_key_pwd2
,
'P'
:
user
.
ssh_pwd
,
}
...
...
@@ -244,7 +239,7 @@ def get_connect_item(username, ip):
elif
asset
.
login_type
==
'M'
:
username
=
asset
.
username
password
=
cryptor
.
decrypt
(
asset
.
password
)
password
=
cryptor
.
decrypt
(
asset
.
password
)
return
username
,
password
,
ip
,
port
else
:
...
...
jperm/views.py
View file @
35d9be5c
...
...
@@ -25,8 +25,11 @@ def perm_group_update(user_group_name='', user_group_id='', asset_groups_name=''
Perm
(
user_group
=
user_group
,
asset_group
=
asset_group
)
.
save
()
def
perm_user_asset
(
user_id
):
def
perm_user_asset
(
user_id
=
None
,
username
=
None
):
if
user_id
:
user
=
User
.
objects
.
get
(
id
=
user_id
)
else
:
user
=
User
.
objects
.
get
(
username
=
username
)
user_groups
=
user
.
user_group
.
all
()
perms
=
[]
assets
=
[]
...
...
@@ -99,84 +102,3 @@ def perm_asset_detail(request):
return
render_to_response
(
'jperm/perm_asset_detail.html'
,
locals
())
# def perm_user_host(username, ips):
# user = User.objects.get(username=username)
# user.perm_set.all().delete()
# for ip in ips:
# asset = Asset.objects.get(ip=ip)
# Perm.objects.create(user=user, asset=asset)
#
#
# def perm_user_edit(request):
# header_title, path1, path2 = u'授权编辑 | Perm Edit.', u'jperm', u'perm_edit'
# if request.method == 'GET':
# if request.GET.get('id', None):
# user_id = request.GET.get('id')
# user = User.objects.get(id=user_id)
# assets = Asset.objects.all()
# assets_permed = []
# for perm in user.perm_set.all():
# assets_permed.append(perm.asset)
# assets_unperm = list(set(assets)-set(assets_permed))
# return render_to_response('jperm/perm_user_edit.html', locals())
# else:
# host_ips = request.POST.getlist('host_permed', '')
# username = request.POST.get('username')
# perm_user_host(username, host_ips)
#
# return HttpResponseRedirect('/jperm/perm_host/')
#
#
# def perm_user_detail(request):
# user_id = request.GET.get('id', '')
# user = User.objects.get(id=user_id)
# host_permed = []
# for perm in user.perm_set.all():
# host_permed.append(perm.asset)
#
# return render_to_response('jperm/perm_detail.html', locals())
#
#
# def perm_group_edit(request):
# if request.method == 'GET':
# group_id = request.GET.get('id', '')
# group = UserGroup.objects.get(id=group_id)
#
# return render_to_response('jperm/perm_group_edit.html')
#
#
# def perm_add(request):
# header_title, path1, path2 = u'添加授权 | Add User perm.', u'授权管理', u'添加授权'
# if request.method == 'GET':
# username = request.GET.get('username', None)
# if not username:
# return HttpResponseRedirect('/')
#
# user = User.objects.get(username=username)
# permed_hosts = []
# for perm in user.perm_set.all():
# permed_hosts.append(perm.asset)
#
# hosts_all = Asset.objects.all()
# hosts = list(set(hosts_all) - set(permed_hosts))
#
# else:
# username = request.POST.get('username', None)
# host_ids = request.POST.getlist('host_ids', None)
#
# user = User.objects.get(username=username)
# for host_id in host_ids:
# asset = Asset.objects.get(id=host_id)
# perm = Perm(user=user, asset=asset)
# perm.save()
# msg = u'添加成功'
#
# return render_to_response('jperm/perm_add.html', locals())
#
#
# def perm_user_show(request):
# header_title, path1, path2 = u'查看授权用户 | Perm User Detail.', u'授权管理', u'用户详情'
# users = User.objects.all()
# return render_to_response('jperm/perm_user_show.html', locals(),)
templates/jperm/perm_group_edit.html
deleted
100644 → 0
View file @
c1686d52
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
<script
type=
"text/javascript"
>
function
move
(
from
,
to
)
{
$
(
"#"
+
from
+
" option"
).
each
(
function
(){
if
(
$
(
this
).
prop
(
"selected"
)
==
true
)
{
$
(
"#"
+
to
).
append
(
this
);
}
});
}
function
move_all
(
from
,
to
){
$
(
"#"
+
from
).
children
().
each
(
function
(){
$
(
"#"
+
to
).
append
(
this
);
});
}
function
search_host
(
text
){
$
(
"#host_unperm"
).
children
().
each
(
function
(){
$
(
this
).
remove
();});
var
permArray
=
[];
$
(
"#host_permed"
).
children
().
each
(
function
(){
permArray
.
push
(
$
(
this
).
text
());
});
$
(
"#host_all"
).
children
().
each
(
function
(){
if
(
$
(
this
).
text
().
search
(
text
)
!=
-
1
&&
permArray
.
indexOf
(
$
(
this
).
text
())
==
-
1
)
{
$
(
"#host_unperm"
).
append
(
$
(
this
).
clone
())
}
});
}
</script>
{% include 'nav_cat_bar.html' %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
class=
"ibox float-e-margins"
>
<!-- title -->
<div
class=
"ibox-title"
>
<h5>
授权编辑表单
<small>
Edit perm of user group
</small></h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
Config option 1
</a>
</li>
<li><a
href=
"#"
>
Config option 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<!-- end title -->
<div
class=
"ibox-content"
>
<div
class=
"row"
>
<div
class=
"col-sm-5 "
>
<div
class=
"form-group"
>
<label></label>
<input
type=
"text"
id=
"host_filter"
placeholder=
"Search"
class=
"form-control"
value=
""
oninput=
"search_host(this.value)"
>
</div>
</div>
<div
class=
"col-sm-1 "
>
<div
class=
"form-group"
>
<label></label>
</div>
</div>
<div
class=
"col-sm-5 "
>
<div
class=
"form-group"
>
<label></label>
<input
type=
"text"
class=
"form-control"
value=
"{{ group.name }}"
readonly
>
</div>
</div>
</div>
<form
method=
"post"
action=
""
>
<input
type=
"text"
name=
"username"
class=
"form-control"
value=
"{{ group.name }}"
style=
"display: none"
>
<div
class=
"row"
>
<div
class=
"col-sm-5"
><h4>
未授权主机
</h4>
<div>
<select
id=
"host_all"
name=
"host_all"
class=
"form-control"
size=
"10"
multiple
style=
"display: none"
>
{% for asset in assets %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
<select
id=
"host_unperm"
name=
"host_unperm"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in assets_unperm %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
<div
class=
"col-sm-1"
>
<div
class=
"btn-group"
style=
"margin-top: 50px;"
>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('host_unperm', 'host_permed')"
><i
class=
"fa fa-chevron-right"
></i></button>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('host_permed', 'host_unperm')"
><i
class=
"fa fa-chevron-left"
></i>
</button>
</div>
</div>
<div
class=
"col-sm-5"
><h4>
授权主机
</h4>
<div>
<select
id=
"host_permed"
name=
"host_permed"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in assets_permed %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"submit"
>
取消
</button>
<button
class=
"btn btn-primary"
type=
"submit"
onclick=
"javascript: (function(){$('#host_permed option').each(function(){$(this).prop('selected', true)})})()"
>
确认保存
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
var
str
=
document
.
location
.
pathname
.
split
(
"/"
)[
1
];
var
str1
=
document
.
location
.
pathname
.
split
(
"/"
)[
2
];
$
(
"#"
+
str
).
addClass
(
'active'
);
$
(
"#"
+
str1
).
addClass
(
'active'
);
</script>
{#
<script
type=
"text/javascript"
>
#
}
{
#
$
(
"#host_permed"
).
children
().
each
(
function
(){
#
}
{
#
$
(
"#host_all"
).
append
(
$
(
this
).
clone
());
#
}
{
##
}
{
#
if
(
$
(
this
).
prop
(
"selected"
)
==
false
)
{
#
}
{
#
$
(
"#host_unperm"
).
append
(
this
);
#
}
{
#
}
#
}
{
##
}
{
#
$
(
"#host_all"
).
children
().
each
(
function
(){
$
(
this
).
prop
(
"selected"
,
false
)});
#
}
{
#
});
#
}
{
#
</script>
#}
{% endblock %}
\ No newline at end of file
templates/jperm/perm_list2.htl.html
deleted
100644 → 0
View file @
c1686d52
This diff is collapsed.
Click to expand it.
templates/jperm/perm_user_edit.html
deleted
100644 → 0
View file @
c1686d52
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
<script
type=
"text/javascript"
>
function
search_host
(
text
){
$
(
"#host_unperm"
).
children
().
each
(
function
(){
$
(
this
).
remove
();});
var
permArray
=
[];
$
(
"#host_permed"
).
children
().
each
(
function
(){
permArray
.
push
(
$
(
this
).
text
());
});
$
(
"#host_all"
).
children
().
each
(
function
(){
if
(
$
(
this
).
text
().
search
(
text
)
!=
-
1
&&
permArray
.
indexOf
(
$
(
this
).
text
())
==
-
1
)
{
$
(
"#host_unperm"
).
append
(
$
(
this
).
clone
())
}
});
}
</script>
{% include 'nav_cat_bar.html' %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
class=
"ibox float-e-margins"
>
<!-- title -->
<div
class=
"ibox-title"
>
<h5>
授权编辑表单
<small>
Edit perm of user
</small></h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
Config option 1
</a>
</li>
<li><a
href=
"#"
>
Config option 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<!-- end title -->
<div
class=
"ibox-content"
>
<div
class=
"row"
>
<div
class=
"col-sm-5 "
>
<div
class=
"form-group"
>
<label></label>
<input
type=
"text"
id=
"host_filter"
placeholder=
"Search"
class=
"form-control"
value=
""
oninput=
"search_host(this.value)"
>
</div>
</div>
<div
class=
"col-sm-1 "
>
<div
class=
"form-group"
>
<label></label>
</div>
</div>
<div
class=
"col-sm-5 "
>
<div
class=
"form-group"
>
<label></label>
<input
type=
"text"
class=
"form-control"
value=
"{{ user.name }}"
readonly
>
</div>
</div>
</div>
<form
method=
"post"
action=
""
>
<input
type=
"text"
name=
"username"
class=
"form-control"
value=
"{{ user.username }}"
style=
"display: none"
>
<div
class=
"row"
>
<div
class=
"col-sm-5"
><h4>
未授权主机
</h4>
<div>
<select
id=
"host_all"
name=
"host_all"
class=
"form-control"
size=
"10"
multiple
style=
"display: none"
>
{% for asset in assets %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
<select
id=
"host_unperm"
name=
"host_unperm"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in assets_unperm %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
<div
class=
"col-sm-1"
>
<div
class=
"btn-group"
style=
"margin-top: 50px;"
>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('host_unperm', 'host_permed')"
><i
class=
"fa fa-chevron-right"
></i></button>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('host_permed', 'host_unperm')"
><i
class=
"fa fa-chevron-left"
></i>
</button>
</div>
</div>
<div
class=
"col-sm-5"
><h4>
授权主机
</h4>
<div>
<select
id=
"host_permed"
name=
"host_permed"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in assets_permed %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"submit"
>
取消
</button>
<button
class=
"btn btn-primary"
type=
"submit"
onclick=
"javascript: (function(){$('#host_permed option').each(function(){$(this).prop('selected', true)})})()"
>
确认保存
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
var
str
=
document
.
location
.
pathname
.
split
(
"/"
)[
1
];
var
str1
=
document
.
location
.
pathname
.
split
(
"/"
)[
2
];
$
(
"#"
+
str
).
addClass
(
'active'
);
$
(
"#"
+
str1
).
addClass
(
'active'
);
</script>
{#
<script
type=
"text/javascript"
>
#
}
{
#
$
(
"#host_permed"
).
children
().
each
(
function
(){
#
}
{
#
$
(
"#host_all"
).
append
(
$
(
this
).
clone
());
#
}
{
##
}
{
#
if
(
$
(
this
).
prop
(
"selected"
)
==
false
)
{
#
}
{
#
$
(
"#host_unperm"
).
append
(
this
);
#
}
{
#
}
#
}
{
##
}
{
#
$
(
"#host_all"
).
children
().
each
(
function
(){
$
(
this
).
prop
(
"selected"
,
false
)});
#
}
{
#
});
#
}
{
#
</script>
#}
{% endblock %}
\ No newline at end of file
templates/jperm/perm_user_show.html
deleted
100644 → 0
View file @
c1686d52
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
用户信息
<small>
show user info.
</small></h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
未启用 1
</a>
</li>
<li><a
href=
"#"
>
未启用 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
style=
"display: block;"
>
<form
method=
"post"
action=
""
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
ID
</th>
<th>
添加授权
</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>
{{ user.id }}
</td>
<td>
{{ user.username }}
</td>
<td><a
href=
"../perm_list/?username={{ user.username }}"
>
查看权限
</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"submit"
>
取消
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
确认删除
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment