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
f9578f44
Unverified
Commit
f9578f44
authored
Jan 07, 2020
by
BaiJiangJie
Committed by
GitHub
Jan 07, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3606 from jumpserver/dev
Dev
parents
a27fb18a
a37e1422
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
58 additions
and
87 deletions
+58
-87
database_app_list.html
...pplications/templates/applications/database_app_list.html
+2
-3
remote_app_list.html
.../applications/templates/applications/remote_app_list.html
+2
-3
const.py
apps/assets/const.py
+0
-12
asset.py
apps/assets/forms/asset.py
+0
-2
user.py
apps/assets/forms/user.py
+0
-2
base.py
apps/assets/models/base.py
+9
-0
asset.py
apps/assets/serializers/asset.py
+0
-13
system_user.py
apps/assets/serializers/system_user.py
+5
-13
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
djangojs.mo
apps/locale/zh/LC_MESSAGES/djangojs.mo
+0
-0
command_execution_create.html
apps/ops/templates/ops/command_execution_create.html
+0
-6
serializers.py
apps/orgs/serializers.py
+0
-13
jumpserver.js
apps/static/js/jumpserver.js
+26
-4
_foot_js.html
apps/templates/_foot_js.html
+2
-5
_nav.html
apps/templates/_nav.html
+4
-2
_nav_user.html
apps/templates/_nav_user.html
+2
-2
0018_auto_20191202_1010.py
apps/terminal/migrations/0018_auto_20191202_1010.py
+1
-1
models.py
apps/terminal/models.py
+1
-1
base_storage_list.html
apps/terminal/templates/terminal/base_storage_list.html
+2
-3
command_list.html
apps/terminal/templates/terminal/command_list.html
+1
-1
session_list.html
apps/terminal/templates/terminal/session_list.html
+1
-1
No files found.
apps/applications/templates/applications/database_app_list.html
View file @
f9578f44
...
...
@@ -5,10 +5,9 @@
{% block table_search %}{% endblock %}
{% block table_container %}
<div
class=
"btn-group uc pull-left m-r-5"
>
<button
class=
"btn btn-sm btn-primary
"
>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle
"
>
{% trans "Create DatabaseApp" %}
</button>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle"
><span
class=
"caret"
></span></button>
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
>
{% for key, value in type_choices %}
<li><a
class=
""
href=
"{% url 'applications:database-app-create' %}?type={{ key }}"
>
{{ value }}
</a></li>
...
...
apps/applications/templates/applications/remote_app_list.html
View file @
f9578f44
...
...
@@ -7,10 +7,9 @@
{% block table_search %}{% endblock %}
{% block table_container %}
<div
class=
"btn-group uc pull-left m-r-5"
>
<button
class=
"btn btn-sm btn-primary
"
>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle
"
>
{% trans "Create RemoteApp" %}
</button>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle"
><span
class=
"caret"
></span></button>
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
>
{% for key, value in type_choices %}
<li><a
class=
""
href=
"{% url 'applications:remote-app-create' %}?type={{ key }}"
>
{{ value }}
</a></li>
...
...
apps/assets/const.py
View file @
f9578f44
# -*- coding: utf-8 -*-
#
from
django.utils.translation
import
ugettext_lazy
as
_
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT
=
_
(
'Cannot contain special characters: [ {} ]'
)
.
format
(
" "
.
join
([
'/'
,
'
\\
'
]))
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
=
r"[/\\]"
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
=
\
_
(
"* The contains characters that are not allowed"
)
apps/assets/forms/asset.py
View file @
f9578f44
...
...
@@ -7,7 +7,6 @@ from common.utils import get_logger
from
orgs.mixins.forms
import
OrgModelForm
from
..models
import
Asset
from
..const
import
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT
logger
=
get_logger
(
__file__
)
...
...
@@ -82,7 +81,6 @@ class AssetCreateUpdateForm(OrgModelForm):
'nodes'
:
_
(
"Node"
),
}
help_texts
=
{
'hostname'
:
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT
,
'admin_user'
:
_
(
'root or other NOPASSWD sudo privilege user existed in asset,'
'If asset is windows or other set any one, more see admin user left menu'
...
...
apps/assets/forms/user.py
View file @
f9578f44
...
...
@@ -6,7 +6,6 @@ from django.utils.translation import gettext_lazy as _
from
common.utils
import
validate_ssh_private_key
,
ssh_pubkey_gen
,
get_logger
from
orgs.mixins.forms
import
OrgModelForm
from
..models
import
AdminUser
,
SystemUser
from
..const
import
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT
logger
=
get_logger
(
__file__
)
__all__
=
[
...
...
@@ -99,7 +98,6 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
}),
}
help_texts
=
{
'name'
:
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT
,
'auto_push'
:
_
(
'Auto push system user to asset'
),
'priority'
:
_
(
'1-100, High level will be using login asset as default, '
'if user was granted more than 2 system user'
),
...
...
apps/assets/models/base.py
View file @
f9578f44
# -*- coding: utf-8 -*-
#
import
io
import
os
import
uuid
from
hashlib
import
md5
...
...
@@ -76,6 +77,14 @@ class AssetUser(OrgModelMixin):
i
=
'-'
.
join
(
str
(
self
.
id
)
.
split
(
'-'
)[:
3
])
return
i
def
get_private_key
(
self
):
if
not
self
.
private_key_obj
:
return
None
string_io
=
io
.
StringIO
()
self
.
private_key_obj
.
write_private_key
(
string_io
)
private_key
=
string_io
.
getvalue
()
return
private_key
def
get_related_assets
(
self
):
assets
=
self
.
assets
.
all
()
return
assets
...
...
apps/assets/serializers/asset.py
View file @
f9578f44
...
...
@@ -8,10 +8,6 @@ from django.utils.translation import ugettext_lazy as _
from
orgs.mixins.serializers
import
BulkOrgResourceModelSerializer
from
common.serializers
import
AdaptedBulkListSerializer
from
..models
import
Asset
,
Node
,
Label
,
Platform
from
..const
import
(
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
)
from
.base
import
ConnectivitySerializer
__all__
=
[
...
...
@@ -100,15 +96,6 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
'org_name'
:
{
'label'
:
_
(
'Org name'
)}
}
@staticmethod
def
validate_hostname
(
hostname
):
pattern
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
search
(
pattern
,
hostname
)
if
res
is
not
None
:
msg
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
hostname
@classmethod
def
setup_eager_loading
(
cls
,
queryset
):
""" Perform necessary eager loading of data. """
...
...
apps/assets/serializers/system_user.py
View file @
f9578f44
...
...
@@ -9,10 +9,6 @@ from common.utils import ssh_pubkey_gen
from
orgs.mixins.serializers
import
BulkOrgResourceModelSerializer
from
assets.models
import
Node
from
..models
import
SystemUser
from
..const
import
(
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
)
from
.base
import
AuthSerializer
,
AuthSerializerMixin
__all__
=
[
...
...
@@ -47,15 +43,6 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
'created_by'
:
{
'read_only'
:
True
},
}
@staticmethod
def
validate_name
(
name
):
pattern
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
search
(
pattern
,
name
)
if
res
is
not
None
:
msg
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
name
def
validate_auto_push
(
self
,
value
):
login_mode
=
self
.
initial_data
.
get
(
"login_mode"
)
protocol
=
self
.
initial_data
.
get
(
"protocol"
)
...
...
@@ -136,6 +123,7 @@ class SystemUserAuthSerializer(AuthSerializer):
"""
系统用户认证信息
"""
private_key
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
SystemUser
...
...
@@ -144,6 +132,10 @@ class SystemUserAuthSerializer(AuthSerializer):
"login_mode"
,
"password"
,
"private_key"
,
]
@staticmethod
def
get_private_key
(
obj
):
return
obj
.
get_private_key
()
class
SystemUserSimpleSerializer
(
serializers
.
ModelSerializer
):
"""
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
f9578f44
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
f9578f44
This diff is collapsed.
Click to expand it.
apps/locale/zh/LC_MESSAGES/djangojs.mo
View file @
f9578f44
No preview for this file type
apps/ops/templates/ops/command_execution_create.html
View file @
f9578f44
...
...
@@ -119,12 +119,6 @@
check
:
{
enable
:
true
},
async
:
{
enable
:
true
,
url
:
url
,
autoParam
:
[
"id=key"
,
"name=n"
,
"level=lv"
],
type
:
'get'
},
view
:
{
dblClickExpand
:
false
,
showLine
:
true
...
...
apps/orgs/serializers.py
View file @
f9578f44
...
...
@@ -4,10 +4,6 @@ from rest_framework.serializers import ModelSerializer
from
rest_framework
import
serializers
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
Domain
,
AdminUser
,
SystemUser
,
Label
from
assets.const
import
(
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
)
from
perms.models
import
AssetPermission
from
common.serializers
import
AdaptedBulkListSerializer
from
.utils
import
set_current_org
,
get_current_org
...
...
@@ -22,15 +18,6 @@ class OrgSerializer(ModelSerializer):
fields
=
'__all__'
read_only_fields
=
[
'created_by'
,
'date_created'
]
@staticmethod
def
validate_name
(
name
):
pattern
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
search
(
pattern
,
name
)
if
res
is
not
None
:
msg
=
GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
name
class
OrgReadSerializer
(
ModelSerializer
):
admins
=
serializers
.
SlugRelatedField
(
slug_field
=
'name'
,
many
=
True
,
read_only
=
True
)
...
...
apps/static/js/jumpserver.js
View file @
f9578f44
...
...
@@ -1237,7 +1237,7 @@ function toSafeDateISOStr(s) {
function
toSafeLocalDateStr
(
d
)
{
var
date
=
safeDate
(
d
);
var
date_s
=
date
.
toLocaleString
(
navigator
.
language
,
{
hour12
:
false
});
var
date_s
=
date
.
toLocaleString
(
getUserLang
()
,
{
hour12
:
false
});
return
date_s
.
split
(
"/"
).
join
(
'-'
)
}
...
...
@@ -1257,7 +1257,7 @@ function getTimeUnits(u) {
"m"
:
"分"
,
"s"
:
"秒"
,
};
if
(
navigator
.
language
===
"zh-CN"
)
{
if
(
getUserLang
()
===
"zh-CN"
)
{
return
units
[
u
]
}
return
u
...
...
@@ -1395,6 +1395,16 @@ function showCeleryTaskLog(taskId) {
window
.
open
(
url
,
''
,
'width=900,height=600'
)
}
function
getUserLang
(){
let
userLangZh
=
document
.
cookie
.
indexOf
(
'django_language=zh'
);
if
(
userLangZh
!==
-
1
){
return
'zh-CN'
}
else
{
return
'en-US'
}
}
function
initDateRangePicker
(
selector
,
options
)
{
if
(
!
options
)
{
options
=
{}
...
...
@@ -1408,6 +1418,15 @@ function initDateRangePicker(selector, options) {
daysOfWeek
:
[
"日"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
],
//汉化处理
monthNames
:
[
"一月"
,
"二月"
,
"三月"
,
"四月"
,
"五月"
,
"六月"
,
"七月"
,
"八月"
,
"九月"
,
"十月"
,
"十一月"
,
"十二月"
],
};
var
enLocale
=
{
format
:
"YYYY-MM-DD HH:mm"
,
separator
:
" - "
,
applyLabel
:
"Apply"
,
cancelLabel
:
"Cancel"
,
resetLabel
:
"Reset"
,
daysOfWeek
:
[
"Su"
,
"Mo"
,
"Tu"
,
"We"
,
"Th"
,
"Fr"
,
"Sa"
],
monthNames
:
[
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
],
};
var
defaultOption
=
{
singleDatePicker
:
true
,
showDropdowns
:
true
,
...
...
@@ -1415,10 +1434,13 @@ function initDateRangePicker(selector, options) {
timePicker24Hour
:
true
,
autoApply
:
true
,
};
var
userLang
=
navigator
.
language
||
navigator
.
userLanguage
;
if
(
userLang
.
indexOf
(
'zh'
)
!==
-
1
)
{
if
(
getUserLang
()
===
'zh-CN'
)
{
defaultOption
.
locale
=
zhLocale
;
}
else
{
// en-US
defaultOption
.
locale
=
enLocale
;
}
options
=
Object
.
assign
(
defaultOption
,
options
);
return
$
(
selector
).
daterangepicker
(
options
);
}
...
...
apps/templates/_foot_js.html
View file @
f9578f44
...
...
@@ -7,7 +7,7 @@
<script
src=
"{% static "
js
/
plugins
/
toastr
/
toastr
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
inspinia
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% url 'javascript-catalog' %}"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
6
"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
7
"
></script>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
<script
src=
"{% static 'js/plugins/select2/i18n/zh-CN.js' %}"
></script>
<script>
...
...
@@ -18,9 +18,6 @@ $(document).ready(function(){
if
(
$
(
'.tooltip'
)[
0
])
{
$
(
'.tooltip'
).
tooltip
();
}
var
userLang
=
navigator
.
language
||
navigator
.
userLanguage
;
if
(
userLang
.
indexOf
(
'zh'
)
!==
-
1
)
{
$
.
fn
.
select2
.
defaults
.
set
(
'language'
,
'zh-CN'
)
}
$
.
fn
.
select2
.
defaults
.
set
(
'language'
,
getUserLang
())
});
</script>
apps/templates/_nav.html
View file @
f9578f44
...
...
@@ -54,13 +54,15 @@
{# Applications #}
{% if request.user.can_admin_current_org
and LICENSE_VALID
%}
{% if request.user.can_admin_current_org %}
<li
id=
"applications"
>
<a>
<i
class=
"fa fa-th"
style=
"width: 14px"
></i>
<span
class=
"nav-label"
>
{% trans 'Applications' %}
</span><span
class=
"fa arrow"
></span>
</a>
<ul
class=
"nav nav-second-level"
>
{% if LICENSE_VALID %}
<li
id=
"remote-app"
><a
href=
"{% url 'applications:remote-app-list' %}"
>
{% trans 'RemoteApp' %}
</a></li>
{% endif %}
<li
id=
"database-app"
><a
href=
"{% url 'applications:database-app-list' %}"
>
{% trans 'DatabaseApp' %}
</a></li>
</ul>
</li>
...
...
@@ -79,10 +81,10 @@
<li
id=
"remote-app-permission"
>
<a
href=
"{% url 'perms:remote-app-permission-list' %}"
>
{% trans 'RemoteApp' %}
</a>
</li>
{% endif %}
<li
id=
"database-app-permission"
>
<a
href=
"{% url 'perms:database-app-permission-list' %}"
>
{% trans 'DatabaseApp' %}
</a>
</li>
{% endif %}
</ul>
</li>
{% endif %}
...
...
apps/templates/_nav_user.html
View file @
f9578f44
...
...
@@ -5,17 +5,18 @@
</a>
</li>
{% if LICENSE_VALID %}
<li
id=
"applications"
>
<a>
<i
class=
"fa fa-th"
style=
"width: 14px"
></i>
<span
class=
"nav-label"
>
{% trans 'My Applications' %}
</span><span
class=
"fa arrow"
></span>
</a>
<ul
class=
"nav nav-second-level"
>
{% if LICENSE_VALID %}
<li
id=
"user-remote-app"
>
<a
href=
"{% url 'applications:user-remote-app-list' %}"
>
<i
class=
""
style=
"width: 14px"
></i><span
class=
"nav-label"
>
{% trans 'RemoteApp' %}
</span><span
class=
"label label-info pull-right"
></span>
</a>
</li>
{% endif %}
<li
id=
"user-database-app"
>
<a
href=
"{% url 'applications:user-database-app-list' %}"
>
<i
class=
""
style=
"width: 14px"
></i><span
class=
"nav-label"
>
{% trans 'DatabaseApp' %}
</span><span
class=
"label label-info pull-right"
></span>
...
...
@@ -23,7 +24,6 @@
</li>
</ul>
</li>
{% endif %}
{% if SECURITY_COMMAND_EXECUTION %}
<li
id=
"ops"
>
...
...
apps/terminal/migrations/0018_auto_20191202_1010.py
View file @
f9578f44
...
...
@@ -41,7 +41,7 @@ class Migration(migrations.Migration):
migrations
.
AlterField
(
model_name
=
'session'
,
name
=
'asset'
,
field
=
models
.
CharField
(
db_index
=
True
,
max_length
=
1
024
,
field
=
models
.
CharField
(
db_index
=
True
,
max_length
=
1
28
,
verbose_name
=
'Asset'
),
),
migrations
.
AlterField
(
...
...
apps/terminal/models.py
View file @
f9578f44
...
...
@@ -175,7 +175,7 @@ class Session(OrgModelMixin):
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
user
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
_
(
"User"
),
db_index
=
True
)
user_id
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
36
,
db_index
=
True
)
asset
=
models
.
CharField
(
max_length
=
1
024
,
verbose_name
=
_
(
"Asset"
),
db_index
=
True
)
asset
=
models
.
CharField
(
max_length
=
1
28
,
verbose_name
=
_
(
"Asset"
),
db_index
=
True
)
asset_id
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
36
,
db_index
=
True
)
system_user
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
_
(
"System user"
),
db_index
=
True
)
system_user_id
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
36
,
db_index
=
True
)
...
...
apps/terminal/templates/terminal/base_storage_list.html
View file @
f9578f44
...
...
@@ -13,10 +13,9 @@
<div
id=
"my-tickets"
class=
"tab-pane active"
>
<div
class=
"panel-body"
>
<div
class=
"btn-group uc pull-left m-r-5"
>
<button
class=
"btn btn-sm btn-primary
"
>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle
"
>
{% block create_storage_info %}{% endblock %}
</button>
<button
data-toggle=
"dropdown"
class=
"btn btn-primary btn-sm dropdown-toggle"
><span
class=
"caret"
></span></button>
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
>
{% for key, value in type_choices %}
<li><a
class=
""
href=
"{% block create_storage_url %}{% endblock %}?type={{ key }}"
>
{{ value }}
</a></li>
...
...
apps/terminal/templates/terminal/command_list.html
View file @
f9578f44
...
...
@@ -86,7 +86,7 @@ $(document).ready(function () {
forceParse
:
false
,
calendarWeeks
:
true
,
autoclose
:
true
,
language
:
navigator
.
language
||
"en"
,
language
:
getUserLang
()
,
};
dateFromRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
var
value
=
$
(
this
).
val
()
+
' 0:0:0'
;
...
...
apps/terminal/templates/terminal/session_list.html
View file @
f9578f44
...
...
@@ -193,7 +193,7 @@ $(document).ready(function() {
forceParse
:
false
,
calendarWeeks
:
true
,
autoclose
:
true
,
language
:
navigator
.
language
||
"en"
,
language
:
getUserLang
()
,
};
dateFromRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
if
(
!
$
(
this
).
val
())
{
...
...
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