mirror of https://github.com/jumpserver/jumpserver
commit
a242bdd3b1
|
@ -75,7 +75,8 @@ class Gateway(AssetUser):
|
|||
pkey=self.private_key_obj)
|
||||
except(paramiko.AuthenticationException,
|
||||
paramiko.BadAuthenticationType,
|
||||
paramiko.SSHException) as e:
|
||||
paramiko.SSHException,
|
||||
paramiko.ssh_exception.NoValidConnectionsError) as e:
|
||||
return False, str(e)
|
||||
|
||||
try:
|
||||
|
|
|
@ -35,12 +35,12 @@ class CommandFilterRuleSerializer(BulkOrgResourceModelSerializer):
|
|||
fields = '__all__'
|
||||
list_serializer_class = AdaptedBulkListSerializer
|
||||
|
||||
def validate_content(self, content):
|
||||
tp = self.initial_data.get("type")
|
||||
if tp == CommandFilterRule.TYPE_REGEX:
|
||||
return content
|
||||
if self.invalid_pattern.search(content):
|
||||
invalid_char = self.invalid_pattern.pattern.replace('\\', '')
|
||||
msg = _("Content should not be contain: {}").format(invalid_char)
|
||||
raise serializers.ValidationError(msg)
|
||||
return content
|
||||
# def validate_content(self, content):
|
||||
# tp = self.initial_data.get("type")
|
||||
# if tp == CommandFilterRule.TYPE_REGEX:
|
||||
# return content
|
||||
# if self.invalid_pattern.search(content):
|
||||
# invalid_char = self.invalid_pattern.pattern.replace('\\', '')
|
||||
# msg = _("Content should not be contain: {}").format(invalid_char)
|
||||
# raise serializers.ValidationError(msg)
|
||||
# return content
|
||||
|
|
|
@ -117,7 +117,7 @@ function initTable() {
|
|||
columns: [
|
||||
{data: function(){return ""}}, {data: "name"}, {data: "username" }, {data: "assets_amount", orderable: false},
|
||||
{#{data: "connectivity_amount"}, {data: "connectivity_amount"}, {data: "connectivity_amount"},#}
|
||||
{data: "comment"}, {data: "id"}
|
||||
{data: "comment"}, {data: "id", orderable: false}
|
||||
]
|
||||
};
|
||||
admin_user_table = jumpserver.initServerSideDataTable(options);
|
||||
|
|
|
@ -62,8 +62,8 @@ function initTable() {
|
|||
],
|
||||
ajax_url: '{% url "api-assets:cmd-filter-list" %}',
|
||||
columns: [
|
||||
{data: "id"}, {data: "name" }, {data: "rules" },
|
||||
{data: "system_users" }, {data: "comment"}, {data: "id"}
|
||||
{data: "id"}, {data: "name" }, {data: "rules", orderable: false},
|
||||
{data: "system_users", orderable: false}, {data: "comment"}, {data: "id", orderable: false}
|
||||
],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
|
@ -90,8 +90,8 @@ function initTable() {
|
|||
],
|
||||
ajax_url: '{% url "api-assets:cmd-filter-rule-list" filter_pk=object.id %}',
|
||||
columns: [
|
||||
{data: "id"}, {data: "type.display" }, {data: 'content'}, {data: 'priority'},
|
||||
{data: 'action.display'}, {data: "comment" }, {data: "id"}
|
||||
{data: "id"}, {data: "type.display", orderable: false }, {data: 'content'}, {data: 'priority'},
|
||||
{data: 'action.display', orderable: false}, {data: "comment" }, {data: "id", orderable: false}
|
||||
],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-9" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span class="label"><b>{{ object.name }}</b></span>
|
||||
|
|
|
@ -106,7 +106,7 @@ function initTable() {
|
|||
ajax_url: '{% url "api-assets:gateway-list" %}?domain={{ object.id }}',
|
||||
columns: [
|
||||
{data: "id"}, {data: "name" }, {data: 'ip'}, {data: 'port'},
|
||||
{data: "protocol"}, {data: "username" }, {data: "comment" }, {data: "id"}
|
||||
{data: "protocol", orderable: false}, {data: "username" }, {data: "comment" }, {data: "id", orderable: false}
|
||||
],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
|
@ -58,8 +58,8 @@ function initTable() {
|
|||
],
|
||||
ajax_url: '{% url "api-assets:domain-list" %}',
|
||||
columns: [
|
||||
{data: "id"}, {data: "name" }, {data: "asset_count" },
|
||||
{data: "gateway_count" }, {data: "comment" }, {data: "id"}
|
||||
{data: "id"}, {data: "name" }, {data: "asset_count", orderable: false },
|
||||
{data: "gateway_count", orderable: false }, {data: "comment" }, {data: "id", orderable: false}
|
||||
],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ function initTable() {
|
|||
ajax_url: '{% url "api-assets:label-list" %}?sort=name',
|
||||
columns: [
|
||||
{data: "id"}, {data: "name" }, {data: "value" },
|
||||
{data: "asset_count" }, {data: "id"}
|
||||
{data: "asset_count", orderable: false}, {data: "id", orderable: false}
|
||||
],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
|
@ -113,7 +113,8 @@
|
|||
"searching": false,
|
||||
"paging": false,
|
||||
"bInfo" : false,
|
||||
"order": []
|
||||
"order": [],
|
||||
"columnDefs": [{"targets": 6, "orderable": false}]
|
||||
});
|
||||
$('.select2').select2({
|
||||
dropdownAutoWidth: true,
|
||||
|
|
|
@ -120,8 +120,8 @@ $(document).ready(function () {
|
|||
}}
|
||||
],
|
||||
ajax_url: '{% url "api-ops:adhoc-list" %}?task={{ object.pk }}',
|
||||
columns: [{data: function(){return ""}}, {data: "short_id" }, {data: "hosts"}, {data: "pattern"},
|
||||
{data: "run_as"}, {data: "become"}, {data: "date_created"}, {data: "id"}]
|
||||
columns: [{data: function(){return ""}}, {data: "short_id" }, {data: "hosts", orderable:false}, {data: "pattern", orderable:false},
|
||||
{data: "run_as"}, {data: "become", orderable:false}, {data: "date_created"}, {data: "id", orderable:false}]
|
||||
};
|
||||
jumpserver.initDataTable(options);
|
||||
}).on('click', '.celery-task-log', function () {
|
||||
|
|
|
@ -140,8 +140,8 @@ function initTable() {
|
|||
}}
|
||||
],
|
||||
ajax_url: '{% url "api-ops:history-list" %}?task={{ object.pk }}',
|
||||
columns: [{data: function(){return ""}}, {data: "date_start"}, {data: "stat"}, {data: "stat"}, {data: "is_finished"},
|
||||
{data: "is_success"}, {data: "timedelta"}, {data: 'adhoc_short_id'}, {data: "id"}]
|
||||
columns: [{data: function(){return ""}}, {data: "date_start"}, {data: "stat", orderable:false}, {data: "stat", orderable:false}, {data: "is_finished"},
|
||||
{data: "is_success"}, {data: "timedelta"}, {data: 'adhoc_short_id'}, {data: "id", orderable:false}]
|
||||
};
|
||||
jumpserver.initDataTable(options);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,13 @@ $(document).ready(function() {
|
|||
"searching": false,
|
||||
"paging": false,
|
||||
"bInfo" : false,
|
||||
"order": []
|
||||
"order": [],
|
||||
"columnDefs": [
|
||||
{ "targets": 0, "orderable": false },
|
||||
{ "targets": 4, "orderable": false },
|
||||
{ "targets": 5, "orderable": false },
|
||||
{ "targets": 8, "orderable": false }
|
||||
]
|
||||
});
|
||||
$('.select2').select2({
|
||||
dropdownAutoWidth : true,
|
||||
|
|
|
@ -6,6 +6,8 @@ from django.core.cache import cache
|
|||
from django.db.models import Q
|
||||
from django.conf import settings
|
||||
from rest_framework.views import Response
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.http import condition
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from common.utils import get_logger
|
||||
|
@ -14,7 +16,7 @@ from ..utils import (
|
|||
AssetPermissionUtil
|
||||
)
|
||||
from .. import const
|
||||
from ..hands import Asset, Node, SystemUser, Label
|
||||
from ..hands import Asset, Node, SystemUser
|
||||
from .. import serializers
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
@ -22,6 +24,17 @@ logger = get_logger(__name__)
|
|||
__all__ = ['UserPermissionCacheMixin', 'GrantAssetsMixin', 'NodesWithUngroupMixin']
|
||||
|
||||
|
||||
def get_etag(request, *args, **kwargs):
|
||||
cache_policy = request.GET.get("cache_policy")
|
||||
if cache_policy != '1':
|
||||
return None
|
||||
view = request.parser_context.get("view")
|
||||
if not view:
|
||||
return None
|
||||
etag = view.get_meta_cache_id()
|
||||
return etag
|
||||
|
||||
|
||||
class UserPermissionCacheMixin:
|
||||
cache_policy = '0'
|
||||
RESP_CACHE_KEY = '_PERMISSION_RESPONSE_CACHE_V2_{}'
|
||||
|
@ -96,6 +109,7 @@ class UserPermissionCacheMixin:
|
|||
cache.set(key, response.data, self.CACHE_TIME)
|
||||
logger.debug("Set response to cache: {}".format(key))
|
||||
|
||||
@method_decorator(condition(etag_func=get_etag))
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.cache_policy = request.GET.get('cache_policy', '0')
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import uuid
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework.views import APIView, Response
|
||||
|
||||
from rest_framework.generics import (
|
||||
ListAPIView, get_object_or_404, RetrieveAPIView
|
||||
)
|
||||
|
|
|
@ -19,17 +19,17 @@
|
|||
</li>
|
||||
<li>
|
||||
<a href="{% url 'perms:asset-permission-user-list' pk=asset_permission.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Users and user groups' %}
|
||||
<i class="fa fa-group"></i> {% trans 'Users and user groups' %}
|
||||
</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<a href="{% url 'perms:asset-permission-asset-list' pk=asset_permission.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Assets and node' %}</a>
|
||||
<i class="fa fa-inbox"></i> {% trans 'Assets and node' %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span style="float: left">{% trans 'Asset list of ' %} <b>{{ asset_permission.name }}</b></span>
|
||||
|
@ -64,7 +64,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Add asset to this permission' %}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
</li>
|
||||
<li>
|
||||
<a href="{% url 'perms:asset-permission-user-list' pk=object.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Users and user groups' %}
|
||||
<i class="fa fa-group"></i> {% trans 'Users and user groups' %}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'perms:asset-permission-asset-list' pk=object.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Assets and node' %}</a>
|
||||
<i class="fa fa-inbox"></i> {% trans 'Assets and node' %}</a>
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<a class="btn btn-outline btn-default" href="{% url 'perms:asset-permission-update' pk=object.id %}"><i class="fa fa-edit"></i>{% trans 'Update' %}</a>
|
||||
|
@ -37,7 +37,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span class="label"><b>{{ object.name }}</b></span>
|
||||
|
@ -108,7 +108,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
|
||||
|
|
|
@ -182,9 +182,9 @@ function initTable() {
|
|||
],
|
||||
ajax_url: '{% url "api-perms:asset-permission-list" %}?display=1',
|
||||
columns: [
|
||||
{data: "id"}, {data: "name"}, {data: "users"},
|
||||
{data: "user_groups"}, {data: "assets"},
|
||||
{data: "nodes"}, {data: "system_users"},
|
||||
{data: "id"}, {data: "name"}, {data: "users", orderable: false},
|
||||
{data: "user_groups", orderable: false}, {data: "assets", orderable: false},
|
||||
{data: "nodes", orderable: false}, {data: "system_users", orderable: false},
|
||||
{data: "is_valid", orderable: false}, {data: "id", orderable: false}
|
||||
],
|
||||
select: {},
|
||||
|
|
|
@ -19,17 +19,17 @@
|
|||
</li>
|
||||
<li class="active">
|
||||
<a href="{% url 'perms:asset-permission-user-list' pk=asset_permission.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Users and user groups' %}
|
||||
<i class="fa fa-group"></i> {% trans 'Users and user groups' %}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'perms:asset-permission-asset-list' pk=asset_permission.id %}" class="text-center">
|
||||
<i class="fa fa-bar-chart-o"></i> {% trans 'Assets and node' %}</a>
|
||||
<i class="fa fa-inbox"></i> {% trans 'Assets and node' %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span style="float: left">{% trans 'User list of ' %} <b>{{ asset_permission.name }}</b></span>
|
||||
|
@ -74,7 +74,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Add user to asset permission' %}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span class="label"><b>{{ object.name }}</b></span>
|
||||
|
@ -100,7 +100,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span style="float: left">{% trans 'RemoteApp list of ' %} <b>{{ remote_app_permission.name }}</b></span>
|
||||
|
@ -73,7 +73,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Add RemoteApp to this permission' %}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="col-sm-7" style="padding-left: 0;">
|
||||
<div class="col-sm-8" style="padding-left: 0;">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<span style="float: left">{% trans 'User list of ' %} <b>{{ remote_app_permission.name }}</b></span>
|
||||
|
@ -73,7 +73,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" style="padding-left: 0;padding-right: 0">
|
||||
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-info-circle"></i> {% trans 'Add user to this permission' %}
|
||||
|
|
|
@ -223,7 +223,7 @@ function formSubmit(props) {
|
|||
return
|
||||
}
|
||||
$.each(errors, function (k, v) {
|
||||
var fieldRef = props.form.find('input[name="' + k + '"]');
|
||||
var fieldRef = props.form.find('[name="' + k + '"]');
|
||||
var formGroupRef = fieldRef.parents('.form-group');
|
||||
var parentRef = fieldRef.parent();
|
||||
var helpBlockRef = parentRef.children('.help-block.error');
|
||||
|
@ -237,7 +237,7 @@ function formSubmit(props) {
|
|||
helpBlockRef.html(help_msg);
|
||||
} else {
|
||||
$.each(v, function (kk, vv) {
|
||||
if (typeof errors === "object") {
|
||||
if (typeof vv === "object") {
|
||||
$.each(vv, function (kkk, vvv) {
|
||||
noneFieldErrorMsg += " " + vvv + '<br/>';
|
||||
})
|
||||
|
|
|
@ -199,8 +199,8 @@ function initTable() {
|
|||
ajax_url: commandListUrl,
|
||||
columns: [
|
||||
{data: "id"}, {data: "input", orderable: false}, {data: "user", orderable: false},
|
||||
{data: "asset"}, {data: "system_user"},
|
||||
{data: "session"}, {data: "timestamp", width: "160px"},
|
||||
{data: "asset", orderable: false}, {data: "system_user", orderable: false},
|
||||
{data: "session", orderable: false}, {data: "timestamp", width: "160px", orderable: false},
|
||||
],
|
||||
select: {},
|
||||
op_html: $('#actions').html(),
|
||||
|
|
|
@ -155,11 +155,11 @@ function initTable() {
|
|||
],
|
||||
ajax_url: sessionListUrl,
|
||||
columns: [
|
||||
{data: "id"}, {data: "id"}, {data: "user", orderable: false},
|
||||
{data: "asset", orderable: false}, {data: "system_user", orderable: false},
|
||||
{data: "remote_addr"}, {data: "protocol"}, {data: "login_from_display"},
|
||||
{data: "command_amount"}, {data: "date_start"},
|
||||
{data: "date_end"}, {data: "id"},
|
||||
{data: "id"}, {data: "id", orderable:false}, {data: "user"},
|
||||
{data: "asset"}, {data: "system_user"},
|
||||
{data: "remote_addr"}, {data: "protocol"}, {data: "login_from_display", orderable:false},
|
||||
{data: "command_amount", orderable:false}, {data: "date_start"},
|
||||
{data: "date_end", orderable:false}, {data: "id",orderable:false},
|
||||
],
|
||||
op_html: $('#actions').html(),
|
||||
fb_html: $("#daterange").html(),
|
||||
|
|
|
@ -90,7 +90,7 @@ function initTable() {
|
|||
],
|
||||
ajax_url: '{% url "api-terminal:terminal-list" %}',
|
||||
columns: [{data: function(){return ""}}, {data: "name" }, {data: "remote_addr" },
|
||||
{data: "session_online"}, {data: "is_active" }, {data: 'is_alive'}, {data: "id"}],
|
||||
{data: "session_online", orderable: false}, {data: "is_active", orderable: false}, {data: 'is_alive'}, {data: "id", orderable: false}],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
jumpserver.initDataTable(options);
|
||||
|
|
|
@ -80,8 +80,8 @@ function initTable() {
|
|||
}}
|
||||
],
|
||||
ajax_url: '{% url "api-users:user-group-list" %}?display=1',
|
||||
columns: [{data: function(){return ""}}, {data: "name" }, {data: "users"},
|
||||
{data: "comment"}, {data: "id" }],
|
||||
columns: [{data: function(){return ""}}, {data: "name" }, {data: "users", orderable: false},
|
||||
{data: "comment"}, {data: "id", orderable: false }],
|
||||
order: [],
|
||||
op_html: $('#actions').html()
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue