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
459d0668
Unverified
Commit
459d0668
authored
Feb 26, 2018
by
liuzheng
Committed by
liuzheng712
Feb 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: replay setting page and api
parent
1f3b11a2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
32 deletions
+66
-32
api.py
apps/common/api.py
+1
-2
forms.py
apps/common/forms.py
+9
-1
terminal_setting.html
apps/common/templates/common/terminal_setting.html
+46
-20
views.py
apps/common/views.py
+3
-0
settings.py
apps/jumpserver/settings.py
+7
-9
No files found.
apps/common/api.py
View file @
459d0668
...
...
@@ -9,7 +9,7 @@ from django.core.mail import get_connection, send_mail
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.conf
import
settings
from
.permissions
import
IsSuperUser
from
.permissions
import
IsSuperUser
,
IsAppUser
from
.serializers
import
MailTestSerializer
,
LDAPTestSerializer
...
...
@@ -102,4 +102,3 @@ class DjangoSettingsAPI(APIView):
if
i
.
isupper
():
configs
[
i
]
=
str
(
getattr
(
settings
,
i
))
return
Response
(
configs
)
apps/common/forms.py
View file @
459d0668
...
...
@@ -127,7 +127,8 @@ class LDAPSettingForm(BaseForm):
"name"
:
"sn"
,
"email"
:
"mail"
}),
help_text
=
_
(
"User attr map present how to map LDAP user attr to jumpserver, username,name,email is jumpserver attr"
)
help_text
=
_
(
"User attr map present how to map LDAP user attr to jumpserver, username,name,email is jumpserver attr"
)
)
# AUTH_LDAP_GROUP_SEARCH_OU = CONFIG.AUTH_LDAP_GROUP_SEARCH_OU
# AUTH_LDAP_GROUP_SEARCH_FILTER = CONFIG.AUTH_LDAP_GROUP_SEARCH_FILTER
...
...
@@ -160,3 +161,10 @@ class TerminalSettingForm(BaseForm):
"You can set other storage and some terminal using"
)
)
TERMINAL_REPLAY_STORAGE
=
DictField
(
label
=
_
(
"Replay storage"
),
help_text
=
_
(
"Set replay storage setting, `default` is the using as default,"
"You can set other storage and some terminal using"
)
)
apps/common/templates/common/terminal_setting.html
View file @
459d0668
...
...
@@ -12,16 +12,20 @@
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{% url 'settings:basic-setting' %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Basic setting' %}
</a>
<a
href=
"{% url 'settings:basic-setting' %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Basic setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
</li>
<li
class=
"active"
>
<a
href=
"{% url 'settings:terminal-setting' %}"
class=
"text-center"
><i
class=
"fa fa-hdd-o"
></i>
{% trans 'Terminal setting' %}
</a>
<a
href=
"{% url 'settings:terminal-setting' %}"
class=
"text-center"
><i
class=
"fa fa-hdd-o"
></i>
{% trans 'Terminal setting' %}
</a>
</li>
</ul>
</div>
...
...
@@ -41,13 +45,14 @@
{% bootstrap_field field layout="horizontal" %}
{% else %}
<div
class=
"form-group"
>
<label
for=
"{{ field.id_for_label }}"
class=
"col-sm-2 control-label"
>
{{ field.label }}
</label>
<label
for=
"{{ field.id_for_label }}"
class=
"col-sm-2 control-label"
>
{{ field.label }}
</label>
<div
class=
"col-sm-8"
>
<div
class=
"col-sm-1"
>
{{ field }}
</div>
<div
class=
"col-sm-9"
>
<span
class=
"help-block"
>
{{ field.help_text }}
</span>
<span
class=
"help-block"
>
{{ field.help_text }}
</span>
</div>
</div>
</div>
...
...
@@ -56,7 +61,7 @@
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans "Command storage" %}
</h3>
<table
class=
"table table-hover "
id=
"task-history-list-table"
>
<table
class=
"table table-hover "
id=
"task-history-list-table"
>
<thead>
<tr>
<th>
{% trans 'Name' %}
</th>
...
...
@@ -72,15 +77,35 @@
{% endfor %}
</tbody>
</table>
{#
<button
class=
"btn btn-default btn-circle btn-add-command-storage"
data-toggle=
"modal"
data-target=
"#add_command_storage_model"
tabindex=
"0"
type=
"button"
><i
class=
"fa fa-plus"
></i></button>
#}
{#
<div
class=
"hr-line-dashed"
></div>
#}
{#
<h3>
{% trans "Replay storage" %}
</h3>
#}
{#
<button
class=
"btn btn-default btn-circle btn-add-command-storage"
data-toggle=
"modal"
data-target=
"#add_command_storage_model"
tabindex=
"0"
type=
"button"
><i
class=
"fa fa-plus"
></i></button>
#}
{#
<div
class=
"hr-line-dashed"
></div>
#}
{#
<h3>
{% trans "Replay storage" %}
</h3>
#}
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans "Replay storage" %}
</h3>
<table
class=
"table table-hover "
id=
"task-history-list-table"
>
<thead>
<tr>
<th>
{% trans 'Name' %}
</th>
<th>
{% trans 'Type' %}
</th>
<th>
{% trans 'Setting' %}
</th>
</tr>
</thead>
<tbody>
{% for name, setting in replay_storage.items %}
<tr>
<td>
{{ name }}
</td>
<td>
{{ setting.TYPE }}
</td>
<td>
{{ setting }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
...
...
@@ -94,10 +119,10 @@
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
})
.
on
(
"click"
,
".btn-test"
,
function
()
{
<script>
$
(
document
).
ready
(
function
()
{
})
.
on
(
"click"
,
".btn-test"
,
function
()
{
var
data
=
{};
var
form
=
$
(
"form"
).
serializeArray
();
$
.
each
(
form
,
function
(
i
,
field
)
{
...
...
@@ -113,6 +138,7 @@ $(document).ready(function () {
function
success
(
message
)
{
toastr
.
success
(
message
.
msg
)
}
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
data
),
...
...
@@ -121,9 +147,9 @@ $(document).ready(function () {
success
:
success
,
error
:
error
});
})
.
on
(
'click'
,
''
,
function
()
{
})
.
on
(
'click'
,
''
,
function
()
{
})
</script>
})
</script>
{% endblock %}
apps/common/views.py
View file @
459d0668
...
...
@@ -97,10 +97,12 @@ class TerminalSettingView(AdminUserRequiredMixin, TemplateView):
def
get_context_data
(
self
,
**
kwargs
):
command_storage
=
settings
.
TERMINAL_COMMAND_STORAGE
replay_storage
=
settings
.
TERMINAL_REPLAY_STORAGE
context
=
{
'app'
:
_
(
'Settings'
),
'action'
:
_
(
'Terminal setting'
),
'form'
:
self
.
form_class
(),
'replay_storage'
:
replay_storage
,
'command_storage'
:
command_storage
,
}
kwargs
.
update
(
context
)
...
...
@@ -117,3 +119,4 @@ class TerminalSettingView(AdminUserRequiredMixin, TemplateView):
context
=
self
.
get_context_data
()
context
.
update
({
"form"
:
form
})
return
render
(
request
,
self
.
template_name
,
context
)
apps/jumpserver/settings.py
View file @
459d0668
...
...
@@ -17,7 +17,6 @@ import ldap
from
django_auth_ldap.config
import
LDAPSearch
from
django.urls
import
reverse_lazy
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
PROJECT_DIR
=
os
.
path
.
dirname
(
BASE_DIR
)
...
...
@@ -39,11 +38,9 @@ SECRET_KEY = CONFIG.SECRET_KEY
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
CONFIG
.
DEBUG
or
False
# Absolute url for some case, for example email link
SITE_URL
=
CONFIG
.
SITE_URL
or
'http://localhost'
# LOG LEVEL
LOG_LEVEL
=
'DEBUG'
if
DEBUG
else
CONFIG
.
LOG_LEVEL
or
'WARNING'
...
...
@@ -114,7 +111,7 @@ LOGIN_URL = reverse_lazy('users:login')
SESSION_COOKIE_DOMAIN
=
CONFIG
.
SESSION_COOKIE_DOMAIN
or
None
CSRF_COOKIE_DOMAIN
=
CONFIG
.
CSRF_COOKIE_DOMAIN
or
None
SESSION_COOKIE_AGE
=
CONFIG
.
SESSION_COOKIE_AGE
or
3600
*
24
SESSION_COOKIE_AGE
=
CONFIG
.
SESSION_COOKIE_AGE
or
3600
*
24
MESSAGE_STORAGE
=
'django.contrib.messages.storage.cookie.CookieStorage'
# Database
...
...
@@ -250,7 +247,6 @@ STATIC_URL = '/static/'
STATIC_ROOT
=
os
.
path
.
join
(
PROJECT_DIR
,
"data"
,
"static"
)
STATIC_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"static"
)
STATICFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
"static"
),
)
...
...
@@ -265,7 +261,7 @@ MEDIA_ROOT = os.path.join(PROJECT_DIR, 'data', 'media').replace('\\', '/') + '/'
# BOOTSTRAP_COLUMN_COUNT = 11
# Init data or generate fake data source for development
FIXTURE_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'fixtures'
),]
FIXTURE_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'fixtures'
),
]
# Email config
EMAIL_HOST
=
CONFIG
.
EMAIL_HOST
...
...
@@ -308,7 +304,6 @@ AUTHENTICATION_BACKENDS = [
# Custom User Auth model
AUTH_USER_MODEL
=
'users.User'
# Auth LDAP settings
AUTH_LDAP
=
CONFIG
.
AUTH_LDAP
AUTH_LDAP_SERVER_URI
=
CONFIG
.
AUTH_LDAP_SERVER_URI
...
...
@@ -332,7 +327,6 @@ AUTH_LDAP_BACKEND = 'django_auth_ldap.backend.LDAPBackend'
if
AUTH_LDAP
:
AUTHENTICATION_BACKENDS
.
insert
(
0
,
AUTH_LDAP_BACKEND
)
# Celery using redis as broker
CELERY_BROKER_URL
=
'redis://:
%(password)
s@
%(host)
s:
%(port)
s/3'
%
{
'password'
:
CONFIG
.
REDIS_PASSWORD
if
CONFIG
.
REDIS_PASSWORD
else
''
,
...
...
@@ -354,7 +348,6 @@ CELERY_REDIRECT_STDOUTS = True
CELERY_REDIRECT_STDOUTS_LEVEL
=
"INFO"
CELERY_WORKER_HIJACK_ROOT_LOGGER
=
False
# Cache use redis
CACHES
=
{
'default'
:
{
...
...
@@ -387,6 +380,11 @@ TERMINAL_COMMAND_STORAGE = {
# },
}
TERMINAL_REPLAY_STORAGE
=
{
"default"
:
{
"TYPE"
:
"server"
,
},
}
# Django bootstrap3 setting, more see http://django-bootstrap3.readthedocs.io/en/latest/settings.html
BOOTSTRAP3
=
{
...
...
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