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
74ab311d
Commit
74ab311d
authored
Oct 09, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改ldap和command
parent
dc5598f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
24 deletions
+37
-24
api.py
apps/settings/api.py
+2
-15
utils.py
apps/settings/utils.py
+13
-5
command_list.html
apps/terminal/templates/terminal/command_list.html
+16
-2
session_detail.html
apps/terminal/templates/terminal/session_detail.html
+6
-2
No files found.
apps/settings/api.py
View file @
74ab311d
...
...
@@ -102,6 +102,7 @@ class LDAPUserListApi(generics.ListAPIView):
if
hasattr
(
self
,
'swagger_fake_view'
):
return
[]
util
=
LDAPUtil
()
try
:
users
=
util
.
search_user_items
()
except
Exception
as
e
:
...
...
@@ -112,20 +113,6 @@ class LDAPUserListApi(generics.ListAPIView):
user
[
'id'
]
=
user
[
'username'
]
return
users
def
filter_queryset
(
self
,
queryset
):
search
=
self
.
request
.
query_params
.
get
(
'search'
)
if
not
search
:
return
queryset
search
=
search
.
lower
()
queryset
=
[
q
for
q
in
queryset
if
search
in
q
[
'username'
]
.
lower
()
or
search
in
q
[
'name'
]
.
lower
()
or
search
in
q
[
'email'
]
.
lower
()
]
return
queryset
def
sort_queryset
(
self
,
queryset
):
order_by
=
self
.
request
.
query_params
.
get
(
'order'
)
if
not
order_by
:
...
...
@@ -139,7 +126,7 @@ class LDAPUserListApi(generics.ListAPIView):
return
queryset
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
queryset
=
self
.
filter_queryset
(
self
.
get_queryset
()
)
queryset
=
self
.
get_queryset
(
)
queryset
=
self
.
sort_queryset
(
queryset
)
page
=
self
.
paginate_queryset
(
queryset
)
if
page
is
not
None
:
...
...
apps/settings/utils.py
View file @
74ab311d
...
...
@@ -81,9 +81,12 @@ class LDAPUtil:
user_item
[
attr
]
=
value
return
user_item
def
_search_user_items_ou
(
self
,
search_ou
,
cookie
=
None
):
def
_search_user_items_ou
(
self
,
search_ou
,
extra_filter
=
None
,
cookie
=
None
):
search_filter
=
self
.
search_filter
%
{
"user"
:
"*"
}
if
extra_filter
:
search_filter
=
'(&({})({}))'
.
format
(
search_filter
,
extra_filter
)
ok
=
self
.
connection
.
search
(
search_ou
,
se
lf
.
search_filter
%
({
"user"
:
"*"
})
,
search_ou
,
se
arch_filter
,
attributes
=
list
(
self
.
attr_map
.
values
()),
paged_size
=
self
.
paged_size
,
paged_cookie
=
cookie
)
...
...
@@ -108,16 +111,21 @@ class LDAPUtil:
cookie
=
self
.
connection
.
result
[
'controls'
][
'1.2.840.113556.1.4.319'
][
'value'
][
'cookie'
]
return
cookie
def
search_user_items
(
self
):
def
search_user_items
(
self
,
q
=
None
):
user_items
=
[]
logger
.
info
(
"Search user items"
)
extra_filter
=
''
if
q
:
for
attr
in
self
.
attr_map
.
values
():
extra_filter
+=
'({}={})'
.
format
(
attr
,
q
)
extra_filter
=
'(|{})'
.
format
(
extra_filter
)
for
search_ou
in
str
(
self
.
search_ougroup
)
.
split
(
"|"
):
logger
.
info
(
"Search user search ou: {}"
.
format
(
search_ou
))
_user_items
=
self
.
_search_user_items_ou
(
search_ou
)
_user_items
=
self
.
_search_user_items_ou
(
search_ou
,
extra_filter
=
extra_filter
)
user_items
.
extend
(
_user_items
)
while
self
.
_cookie
():
logger
.
info
(
"Page Search user search ou: {}"
.
format
(
search_ou
))
_user_items
=
self
.
_search_user_items_ou
(
search_ou
,
self
.
_cookie
())
_user_items
=
self
.
_search_user_items_ou
(
search_ou
,
extra_filter
,
self
.
_cookie
())
user_items
.
extend
(
_user_items
)
logger
.
info
(
"Search user items end"
)
return
user_items
...
...
apps/terminal/templates/terminal/command_list.html
View file @
74ab311d
...
...
@@ -164,11 +164,14 @@ $(document).ready(function () {
detailRows
.
push
(
tr
.
attr
(
'id'
));
}
}
})
})
;
function
format
(
d
)
{
var
output
=
$
(
"<pre style='border: none; background: none'></pre>"
);
output
.
append
(
'$ '
,
d
.
input
);
output
.
append
(
'
\
r
\
n
\
r
\
n'
);
output
.
append
(
d
.
output
);
return
output
}
...
...
@@ -187,6 +190,17 @@ function initTable() {
$
(
td
).
addClass
(
"toggle"
);
$
(
td
).
html
(
"<i class='fa fa-angle-right'></i>"
);
}},
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
)
{
var
data
=
htmlEscape
(
cellData
);
var
interHtml
=
$
(
"<span></span>"
);
if
(
data
.
length
>
40
)
{
interHtml
.
attr
(
'title'
,
data
);
data
=
data
.
slice
(
0
,
40
);
data
+=
' ...'
;
}
interHtml
.
html
(
data
);
$
(
td
).
html
(
interHtml
);
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
var
data
=
'<a href="{% url "terminal:session-detail" pk=DEFAULT_PK %}">{% trans "Goto" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
...
...
@@ -200,7 +214,7 @@ function initTable() {
toggle
:
true
,
ajax_url
:
commandListUrl
,
columns
:
[
{
data
:
"id"
},
{
data
:
"input"
,
orderable
:
false
},
{
data
:
"user"
,
orderable
:
false
},
{
data
:
"id"
},
{
data
:
"input"
,
orderable
:
false
,
width
:
"40%"
},
{
data
:
"user"
,
orderable
:
false
},
{
data
:
"asset"
,
orderable
:
false
},
{
data
:
"system_user"
,
orderable
:
false
},
{
data
:
"session"
,
orderable
:
false
},
{
data
:
"timestamp"
,
width
:
"160px"
,
orderable
:
false
},
],
...
...
apps/terminal/templates/terminal/session_detail.html
View file @
74ab311d
...
...
@@ -54,8 +54,12 @@
{% for command in object_list %}
<tr>
<td>
{{ forloop.counter }}
</td>
<td>
{{ command.input }}
</td>
<td><pre
style=
"border: none;background: none"
>
{{ command.output }}
</pre></td>
<td>
{{ command.input | truncatechars:40 }}
</td>
<td><pre
style=
"border: none;background: none"
>
$ {{ command.input }}
<br>
{{ command.output }}
</pre></td>
<td>
{{ command.timestamp|ts_to_date}}
</td>
</tr>
{% empty %}
...
...
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