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
6b1b3348
Commit
6b1b3348
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一些js, setting的KEY_DIR, 下载秘钥鉴定
parent
1471e0a2
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
lagacy-0.4.0
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
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.3.3
0.3.2
0.3.2-rc2
0.3.1
0.3.0-beta
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
12 deletions
+31
-12
jumpserver.conf
jumpserver.conf
+1
-1
api.py
jumpserver/api.py
+3
-1
settings.py
jumpserver/settings.py
+1
-1
mytags.py
jumpserver/templatetags/mytags.py
+11
-0
user_api.py
juser/user_api.py
+3
-3
asset_edit_batch.html
templates/jasset/asset_edit_batch.html
+5
-5
user_list.html
templates/juser/user_list.html
+7
-1
No files found.
jumpserver.conf
View file @
6b1b3348
...
@@ -9,7 +9,7 @@ log = debug
...
@@ -9,7 +9,7 @@ log = debug
host
=
127
.
0
.
0
.
1
host
=
127
.
0
.
0
.
1
port
=
3306
port
=
3306
user
=
jumpserver
user
=
jumpserver
password
=
mysql
1
234
password
=
mysql234
database
=
jumpserver
database
=
jumpserver
[
websocket
]
[
websocket
]
...
...
This diff is collapsed.
Click to expand it.
jumpserver/api.py
View file @
6b1b3348
...
@@ -386,7 +386,7 @@ def bash(cmd):
...
@@ -386,7 +386,7 @@ def bash(cmd):
return
subprocess
.
call
(
cmd
,
shell
=
True
)
return
subprocess
.
call
(
cmd
,
shell
=
True
)
def
mkdir
(
dir_name
,
mode
=
0755
):
def
mkdir
(
dir_name
,
username
=
'root'
,
mode
=
0755
):
"""
"""
insure the dir exist and mode ok
insure the dir exist and mode ok
目录存在,如果不存在就建立,并且权限正确
目录存在,如果不存在就建立,并且权限正确
...
@@ -394,6 +394,8 @@ def mkdir(dir_name, mode=0755):
...
@@ -394,6 +394,8 @@ def mkdir(dir_name, mode=0755):
if
not
os
.
path
.
isdir
(
dir_name
):
if
not
os
.
path
.
isdir
(
dir_name
):
os
.
makedirs
(
dir_name
)
os
.
makedirs
(
dir_name
)
os
.
chmod
(
dir_name
,
mode
)
os
.
chmod
(
dir_name
,
mode
)
if
username
:
bash
(
'chown
%
s:
%
s
%
s'
%
(
username
,
username
,
dir_name
))
def
http_success
(
request
,
msg
):
def
http_success
(
request
,
msg
):
...
...
This diff is collapsed.
Click to expand it.
jumpserver/settings.py
View file @
6b1b3348
...
@@ -17,7 +17,7 @@ config = ConfigParser.ConfigParser()
...
@@ -17,7 +17,7 @@ config = ConfigParser.ConfigParser()
BASE_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)))
BASE_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)))
config
.
read
(
os
.
path
.
join
(
BASE_DIR
,
'jumpserver.conf'
))
config
.
read
(
os
.
path
.
join
(
BASE_DIR
,
'jumpserver.conf'
))
KEY_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'keys
/role_keys
'
)
KEY_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'keys'
)
DB_HOST
=
config
.
get
(
'db'
,
'host'
)
DB_HOST
=
config
.
get
(
'db'
,
'host'
)
...
...
This diff is collapsed.
Click to expand it.
jumpserver/templatetags/mytags.py
View file @
6b1b3348
...
@@ -226,3 +226,14 @@ def ip_str_to_list(ip_str):
...
@@ -226,3 +226,14 @@ def ip_str_to_list(ip_str):
ip str to list
ip str to list
"""
"""
return
ip_str
.
split
(
','
)
return
ip_str
.
split
(
','
)
@register.filter
(
name
=
'key_exist'
)
def
key_exist
(
username
):
"""
ssh key is exist or not
"""
if
os
.
path
.
isfile
(
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
)):
return
True
else
:
return
False
This diff is collapsed.
Click to expand it.
juser/user_api.py
View file @
6b1b3348
...
@@ -123,21 +123,21 @@ def db_del_user(username):
...
@@ -123,21 +123,21 @@ def db_del_user(username):
def
gen_ssh_key
(
username
,
password
=
''
,
def
gen_ssh_key
(
username
,
password
=
''
,
key_dir
=
os
.
path
.
join
(
KEY_DIR
,
'user'
),
key_dir
=
os
.
path
.
join
(
KEY_DIR
,
'user'
),
authorized_keys
=
True
,
home
=
"/home"
,
length
=
2048
):
authorized_keys
=
True
,
home
=
"/home"
,
length
=
2048
):
"""
"""
generate a user ssh key in a property dir
generate a user ssh key in a property dir
生成一个用户ssh密钥对
生成一个用户ssh密钥对
"""
"""
logger
.
debug
(
'生成ssh key, 并设置authorized_keys'
)
private_key_file
=
os
.
path
.
join
(
key_dir
,
username
)
private_key_file
=
os
.
path
.
join
(
key_dir
,
username
)
mkdir
(
private_key_file
,
username
)
mkdir
(
key_dir
)
if
os
.
path
.
isfile
(
private_key_file
):
if
os
.
path
.
isfile
(
private_key_file
):
os
.
unlink
(
private_key_file
)
os
.
unlink
(
private_key_file
)
ret
=
bash
(
'echo -e "y
\n
"|ssh-keygen -t rsa -f
%
s -b
%
s -P "
%
s"'
%
(
private_key_file
,
length
,
password
))
ret
=
bash
(
'echo -e "y
\n
"|ssh-keygen -t rsa -f
%
s -b
%
s -P "
%
s"'
%
(
private_key_file
,
length
,
password
))
if
authorized_keys
:
if
authorized_keys
:
auth_key_dir
=
os
.
path
.
join
(
home
,
username
,
'.ssh'
)
auth_key_dir
=
os
.
path
.
join
(
home
,
username
,
'.ssh'
)
mkdir
(
auth_key_dir
,
username
,
mode
=
0700
)
mkdir
(
auth_key_dir
,
mode
=
0700
)
authorized_key_file
=
os
.
path
.
join
(
auth_key_dir
,
'authorized_keys'
)
authorized_key_file
=
os
.
path
.
join
(
auth_key_dir
,
'authorized_keys'
)
with
open
(
private_key_file
+
'.pub'
)
as
pub_f
:
with
open
(
private_key_file
+
'.pub'
)
as
pub_f
:
with
open
(
authorized_key_file
,
'w'
)
as
auth_f
:
with
open
(
authorized_key_file
,
'w'
)
as
auth_f
:
...
...
This diff is collapsed.
Click to expand it.
templates/jasset/asset_edit_batch.html
View file @
6b1b3348
...
@@ -54,17 +54,17 @@
...
@@ -54,17 +54,17 @@
<div
class=
"col-sm-2"
>
<div
class=
"col-sm-2"
>
<div
class=
"radio i-checks"
>
<div
class=
"radio i-checks"
>
<label>
<label>
<input
type=
"radio"
checked=
""
value=
"no_action"
name=
"use_default_
auth"
><span>
不修改
</span>
<input
type=
"radio"
checked=
""
value=
"no_action"
id=
"no"
name=
"use_default_auth"
class=
"
auth"
><span>
不修改
</span>
</label>
</label>
</div>
</div>
<div
class=
"radio i-checks"
>
<div
class=
"radio i-checks"
>
<label>
<label>
<input
type=
"radio"
name=
"use_default_
auth"
><span>
使用默认
</span>
<input
type=
"radio"
id=
"default"
name=
"use_default_auth"
class=
"
auth"
><span>
使用默认
</span>
</label>
</label>
</div>
</div>
<div
class=
"radio i-checks"
>
<div
class=
"radio i-checks"
>
<label>
<label>
<input
type=
"radio"
id=
"
id_use_default_auth"
name=
"use_default_
auth"
><span>
用户名密码
</span>
<input
type=
"radio"
id=
"
pass"
name=
"use_default_auth"
class=
"
auth"
><span>
用户名密码
</span>
</label>
</label>
</div>
</div>
</div>
</div>
...
@@ -140,8 +140,8 @@
...
@@ -140,8 +140,8 @@
$
(
'#uuid'
).
val
(
ids
)
$
(
'#uuid'
).
val
(
ids
)
});
});
$
(
'
#id_use_default_
auth'
).
click
(
function
(){
$
(
'
.
auth'
).
click
(
function
(){
if
(
$
(
this
).
is
(
':checked'
)
){
if
(
$
(
this
).
attr
(
'id'
)
==
'pass'
){
$
(
'#admin_account'
).
css
(
'display'
,
'block'
)
$
(
'#admin_account'
).
css
(
'display'
,
'block'
)
}
}
else
{
else
{
...
...
This diff is collapsed.
Click to expand it.
templates/juser/user_list.html
View file @
6b1b3348
...
@@ -64,7 +64,13 @@
...
@@ -64,7 +64,13 @@
<td
class=
"text-center"
title=
"{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"
>
{{ user.group.all | groups2str }}
</td>
<td
class=
"text-center"
title=
"{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"
>
{{ user.group.all | groups2str }}
</td>
<td
class=
"text-center"
>
{{ user.id | get_role }}
</td>
<td
class=
"text-center"
>
{{ user.id | get_role }}
</td>
<td
class=
"text-center"
>
{{ user.is_active | bool2str }}
</td>
<td
class=
"text-center"
>
{{ user.is_active | bool2str }}
</td>
<td
class=
"text-center"
><a
href=
"/juser/down_key/?id={{ user.id }}"
>
下载
</a></td>
<td
class=
"text-center"
>
{% if user.username|key_exist %}
<a
href=
"/juser/down_key/?id={{ user.id }}"
>
下载
</a>
{% else %}
<span
style=
"color: #586b7d"
>
下载
</span>
{% endif %}
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<a
href=
"../user_detail/?id={{ user.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"../user_detail/?id={{ user.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"../user_edit/?id={{ user.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"../user_edit/?id={{ user.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
...
...
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