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
f1f06491
Commit
f1f06491
authored
7 years ago
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] 添加功能, 支持 telnet server.
parent
2e6d238c
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
15 deletions
+41
-15
asset.py
apps/assets/forms/asset.py
+2
-2
user.py
apps/assets/forms/user.py
+2
-1
asset.py
apps/assets/models/asset.py
+14
-0
user.py
apps/assets/models/user.py
+2
-0
asset.py
apps/assets/serializers/asset.py
+1
-1
_system_user.html
apps/assets/templates/assets/_system_user.html
+9
-2
asset_create.html
apps/assets/templates/assets/asset_create.html
+6
-5
asset_update.html
apps/assets/templates/assets/asset_update.html
+1
-0
django.mo
apps/i18n/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/i18n/zh/LC_MESSAGES/django.po
+0
-0
api.py
apps/perms/api.py
+4
-4
No files found.
apps/assets/forms/asset.py
View file @
f1f06491
...
@@ -16,7 +16,7 @@ class AssetCreateForm(forms.ModelForm):
...
@@ -16,7 +16,7 @@ class AssetCreateForm(forms.ModelForm):
fields
=
[
fields
=
[
'hostname'
,
'ip'
,
'public_ip'
,
'port'
,
'comment'
,
'hostname'
,
'ip'
,
'public_ip'
,
'port'
,
'comment'
,
'nodes'
,
'is_active'
,
'admin_user'
,
'labels'
,
'platform'
,
'nodes'
,
'is_active'
,
'admin_user'
,
'labels'
,
'platform'
,
'domain'
,
'domain'
,
'protocol'
,
]
]
widgets
=
{
widgets
=
{
...
@@ -56,7 +56,7 @@ class AssetUpdateForm(forms.ModelForm):
...
@@ -56,7 +56,7 @@ class AssetUpdateForm(forms.ModelForm):
fields
=
[
fields
=
[
'hostname'
,
'ip'
,
'port'
,
'nodes'
,
'is_active'
,
'platform'
,
'hostname'
,
'ip'
,
'port'
,
'nodes'
,
'is_active'
,
'platform'
,
'public_ip'
,
'number'
,
'comment'
,
'admin_user'
,
'labels'
,
'public_ip'
,
'number'
,
'comment'
,
'admin_user'
,
'labels'
,
'domain'
,
'domain'
,
'protocol'
,
]
]
widgets
=
{
widgets
=
{
'nodes'
:
forms
.
SelectMultiple
(
attrs
=
{
'nodes'
:
forms
.
SelectMultiple
(
attrs
=
{
...
...
This diff is collapsed.
Click to expand it.
apps/assets/forms/user.py
View file @
f1f06491
...
@@ -94,10 +94,11 @@ class SystemUserForm(PasswordAndKeyAuthForm):
...
@@ -94,10 +94,11 @@ class SystemUserForm(PasswordAndKeyAuthForm):
system_user
=
super
()
.
save
()
system_user
=
super
()
.
save
()
password
=
self
.
cleaned_data
.
get
(
'password'
,
''
)
or
None
password
=
self
.
cleaned_data
.
get
(
'password'
,
''
)
or
None
login_mode
=
self
.
cleaned_data
.
get
(
'login_mode'
,
''
)
or
None
login_mode
=
self
.
cleaned_data
.
get
(
'login_mode'
,
''
)
or
None
protocol
=
self
.
cleaned_data
.
get
(
'protocol'
)
or
None
auto_generate_key
=
self
.
cleaned_data
.
get
(
'auto_generate_key'
,
False
)
auto_generate_key
=
self
.
cleaned_data
.
get
(
'auto_generate_key'
,
False
)
private_key
,
public_key
=
super
()
.
gen_keys
()
private_key
,
public_key
=
super
()
.
gen_keys
()
if
login_mode
==
SystemUser
.
MANUAL_LOGIN
:
if
login_mode
==
SystemUser
.
MANUAL_LOGIN
or
protocol
==
SystemUser
.
TELNET_PROTOCOL
:
system_user
.
auto_push
=
0
system_user
.
auto_push
=
0
system_user
.
save
()
system_user
.
save
()
...
...
This diff is collapsed.
Click to expand it.
apps/assets/models/asset.py
View file @
f1f06491
...
@@ -57,13 +57,27 @@ class Asset(models.Model):
...
@@ -57,13 +57,27 @@ class Asset(models.Model):
(
'MacOS'
,
'MacOS'
),
(
'MacOS'
,
'MacOS'
),
(
'BSD'
,
'BSD'
),
(
'BSD'
,
'BSD'
),
(
'Windows'
,
'Windows'
),
(
'Windows'
,
'Windows'
),
(
'Windows2016'
,
'Windows(2016)'
),
(
'Other'
,
'Other'
),
(
'Other'
,
'Other'
),
)
)
SSH_PROTOCOL
=
'ssh'
RDP_PROTOCOL
=
'rdp'
TELNET_PROTOCOL
=
'telnet'
PROTOCOL_CHOICES
=
(
(
SSH_PROTOCOL
,
'ssh'
),
(
RDP_PROTOCOL
,
'rdp'
),
(
TELNET_PROTOCOL
,
'telnet (beta)'
),
)
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
db_index
=
True
)
db_index
=
True
)
hostname
=
models
.
CharField
(
max_length
=
128
,
unique
=
True
,
hostname
=
models
.
CharField
(
max_length
=
128
,
unique
=
True
,
verbose_name
=
_
(
'Hostname'
))
verbose_name
=
_
(
'Hostname'
))
protocol
=
models
.
CharField
(
max_length
=
128
,
default
=
SSH_PROTOCOL
,
choices
=
PROTOCOL_CHOICES
,
verbose_name
=
_
(
'Protocol'
))
port
=
models
.
IntegerField
(
default
=
22
,
verbose_name
=
_
(
'Port'
))
port
=
models
.
IntegerField
(
default
=
22
,
verbose_name
=
_
(
'Port'
))
platform
=
models
.
CharField
(
max_length
=
128
,
choices
=
PLATFORM_CHOICES
,
platform
=
models
.
CharField
(
max_length
=
128
,
choices
=
PLATFORM_CHOICES
,
default
=
'Linux'
,
verbose_name
=
_
(
'Platform'
))
default
=
'Linux'
,
verbose_name
=
_
(
'Platform'
))
...
...
This diff is collapsed.
Click to expand it.
apps/assets/models/user.py
View file @
f1f06491
...
@@ -95,9 +95,11 @@ class AdminUser(AssetUser):
...
@@ -95,9 +95,11 @@ class AdminUser(AssetUser):
class
SystemUser
(
AssetUser
):
class
SystemUser
(
AssetUser
):
SSH_PROTOCOL
=
'ssh'
SSH_PROTOCOL
=
'ssh'
RDP_PROTOCOL
=
'rdp'
RDP_PROTOCOL
=
'rdp'
TELNET_PROTOCOL
=
'telnet'
PROTOCOL_CHOICES
=
(
PROTOCOL_CHOICES
=
(
(
SSH_PROTOCOL
,
'ssh'
),
(
SSH_PROTOCOL
,
'ssh'
),
(
RDP_PROTOCOL
,
'rdp'
),
(
RDP_PROTOCOL
,
'rdp'
),
(
TELNET_PROTOCOL
,
'telnet (beta)'
),
)
)
AUTO_LOGIN
=
'auto'
AUTO_LOGIN
=
'auto'
...
...
This diff is collapsed.
Click to expand it.
apps/assets/serializers/asset.py
View file @
f1f06491
...
@@ -43,7 +43,7 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
...
@@ -43,7 +43,7 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
fields
=
(
fields
=
(
"id"
,
"hostname"
,
"ip"
,
"port"
,
"system_users_granted"
,
"id"
,
"hostname"
,
"ip"
,
"port"
,
"system_users_granted"
,
"is_active"
,
"system_users_join"
,
"os"
,
'domain'
,
"is_active"
,
"system_users_join"
,
"os"
,
'domain'
,
"platform"
,
"comment"
"platform"
,
"comment"
,
"protocol"
,
)
)
@staticmethod
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/_system_user.html
View file @
f1f06491
...
@@ -104,7 +104,14 @@ function protocolChange() {
...
@@ -104,7 +104,14 @@ function protocolChange() {
$
.
each
(
need_change_field
,
function
(
index
,
value
)
{
$
.
each
(
need_change_field
,
function
(
index
,
value
)
{
$
(
value
).
closest
(
'.form-group'
).
addClass
(
'hidden'
)
$
(
value
).
closest
(
'.form-group'
).
addClass
(
'hidden'
)
});
});
}
else
{
}
else
if
(
$
(
protocol_id
+
" option:selected"
).
text
()
===
'telnet (beta)'
)
{
$
(
'.auth-fields'
).
removeClass
(
'hidden'
);
$
.
each
(
need_change_field
,
function
(
index
,
value
)
{
$
(
value
).
closest
(
'.form-group'
).
addClass
(
'hidden'
)
});
}
else
{
if
(
$
(
login_mode_id
).
val
()
===
'manual'
){
if
(
$
(
login_mode_id
).
val
()
===
'manual'
){
$
(
sudo_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
$
(
sudo_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
$
(
shell_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
$
(
shell_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
...
@@ -133,8 +140,8 @@ function loginModeChange(){
...
@@ -133,8 +140,8 @@ function loginModeChange(){
}
}
else
if
(
$
(
login_mode_id
).
val
()
===
'auto'
){
else
if
(
$
(
login_mode_id
).
val
()
===
'auto'
){
$
(
'#auth_title_id'
).
removeClass
(
'hidden'
);
$
(
'#auth_title_id'
).
removeClass
(
'hidden'
);
protocolChange
();
$
(
password_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
)
$
(
password_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
)
protocolChange
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/asset_create.html
View file @
f1f06491
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.protocol layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.domain layout="horizontal" %}
{% bootstrap_field form.domain layout="horizontal" %}
...
@@ -85,14 +86,14 @@ $(document).ready(function () {
...
@@ -85,14 +86,14 @@ $(document).ready(function () {
allowClear
:
true
,
allowClear
:
true
,
templateSelection
:
format
templateSelection
:
format
});
});
$
(
"#id_p
latform
"
).
change
(
function
(){
$
(
"#id_p
rotocol
"
).
change
(
function
(){
var
p
latform
=
$
(
"#id_platform
option:selected"
).
text
();
var
p
rotocol
=
$
(
"#id_protocol
option:selected"
).
text
();
var
port
=
22
;
var
port
=
22
;
if
(
p
latform
===
'Windows
'
){
if
(
p
rotocol
===
'rdp
'
){
port
=
3389
;
port
=
3389
;
}
}
if
(
p
latform
===
'Other
'
){
if
(
p
rotocol
===
'telnet (beta)
'
){
port
=
null
;
port
=
23
;
}
}
$
(
"#id_port"
).
val
(
port
);
$
(
"#id_port"
).
val
(
port
);
});
});
...
...
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/asset_update.html
View file @
f1f06491
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
<h3>
{% trans 'Basic' %}
</h3>
<h3>
{% trans 'Basic' %}
</h3>
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.protocol layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
...
...
This diff is collapsed.
Click to expand it.
apps/i18n/zh/LC_MESSAGES/django.mo
View file @
f1f06491
No preview for this file type
This diff is collapsed.
Click to expand it.
apps/i18n/zh/LC_MESSAGES/django.po
View file @
f1f06491
This diff is collapsed.
Click to expand it.
apps/perms/api.py
View file @
f1f06491
...
@@ -73,9 +73,9 @@ class UserGrantedAssetsApi(ListAPIView):
...
@@ -73,9 +73,9 @@ class UserGrantedAssetsApi(ListAPIView):
util
=
AssetPermissionUtil
(
user
)
util
=
AssetPermissionUtil
(
user
)
for
k
,
v
in
util
.
get_assets
()
.
items
():
for
k
,
v
in
util
.
get_assets
()
.
items
():
if
k
.
is_unixlike
():
if
k
.
is_unixlike
():
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'ssh'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'ssh'
,
'telnet'
]
]
else
:
else
:
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'rdp'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'rdp'
,
'telnet'
]
]
k
.
system_users_granted
=
system_users_granted
k
.
system_users_granted
=
system_users_granted
queryset
.
append
(
k
)
queryset
.
append
(
k
)
return
queryset
return
queryset
...
@@ -124,9 +124,9 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
...
@@ -124,9 +124,9 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
assets
=
_assets
.
keys
()
assets
=
_assets
.
keys
()
for
k
,
v
in
_assets
.
items
():
for
k
,
v
in
_assets
.
items
():
if
k
.
is_unixlike
():
if
k
.
is_unixlike
():
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'ssh'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'ssh'
,
'telnet'
]
]
else
:
else
:
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'rdp'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'rdp'
,
'telnet'
]
]
k
.
system_users_granted
=
system_users_granted
k
.
system_users_granted
=
system_users_granted
node
.
assets_granted
=
assets
node
.
assets_granted
=
assets
queryset
.
append
(
node
)
queryset
.
append
(
node
)
...
...
This diff is collapsed.
Click to expand it.
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