Merge branch 'dev' into tree

pull/1043/head
ibuler 2018-02-06 13:02:30 +08:00
commit d047ff3b3a
12 changed files with 295 additions and 281 deletions

View File

@ -24,9 +24,16 @@ Jumpserver是一款使用Python, Django开发的开源跳板机系统, 助力互
* Python 3.6 * Python 3.6
* Django 1.11 * Django 1.11
### Install 安装 ### 快速启动
   [详细安装](https://github.com/jumpserver/jumpserver/wiki/v0.5.0-%E5%9F%BA%E4%BA%8E-CentOS7) ```
$ docker run -p 8080:80 -p 2222:2222 jumpserver/jumpserver:0.5.0-beta2
```
更多见 [Dockerfile](https://github.com/jumpserver/Dockerfile.git)
### 详细安装步骤
   [文档](https://github.com/jumpserver/jumpserver/wiki/v0.5.0-%E5%9F%BA%E4%BA%8E-CentOS7)
### Usage 使用 ### Usage 使用
@ -70,6 +77,11 @@ demo使用了开发者模式并发只能为1
参见 https://github.com/jumpserver/jumpserver/milestone/2 参见 https://github.com/jumpserver/jumpserver/milestone/2
### SDK
- python: https://github.com/jumpserver/jumpserver-python-sdk
- java: https://github.com/KaiJunYan/jumpserver-java-sdk.git
### Docs 开发者文档 ### Docs 开发者文档

View File

@ -127,7 +127,7 @@ class AssetBulkUpdateForm(forms.ModelForm):
attrs={'class': 'select2', 'data-placeholder': _('Select asset groups')} attrs={'class': 'select2', 'data-placeholder': _('Select asset groups')}
), ),
'labels': forms.SelectMultiple( 'labels': forms.SelectMultiple(
attrs={'class': 'select2', 'data-placeholder': _('Select lables')} attrs={'class': 'select2', 'data-placeholder': _('Select labels')}
), ),
} }
@ -308,7 +308,7 @@ class SystemUserForm(PasswordAndKeyAuthForm):
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 not self.instance and auto_generate_key: if auto_generate_key:
logger.info('Auto generate key and set system user auth') logger.info('Auto generate key and set system user auth')
system_user.auto_gen_auth() system_user.auto_gen_auth()
else: else:

View File

@ -212,8 +212,10 @@ class AdminUser(AssetUser):
class SystemUser(AssetUser): class SystemUser(AssetUser):
SSH_PROTOCOL = 'ssh' SSH_PROTOCOL = 'ssh'
RDP_PROTOCOL = 'rdp'
PROTOCOL_CHOICES = ( PROTOCOL_CHOICES = (
(SSH_PROTOCOL, 'ssh'), (SSH_PROTOCOL, 'ssh'),
(RDP_PROTOCOL, 'rdp'),
) )
cluster = models.ManyToManyField('assets.Cluster', blank=True, verbose_name=_("Cluster")) cluster = models.ManyToManyField('assets.Cluster', blank=True, verbose_name=_("Cluster"))

View File

@ -297,7 +297,7 @@ class LabelSerializer(serializers.ModelSerializer):
@staticmethod @staticmethod
def get_asset_count(obj): def get_asset_count(obj):
return obj.asset_count return obj.assets.count()
def get_field_names(self, declared_fields, info): def get_field_names(self, declared_fields, info):
fields = super().get_field_names(declared_fields, info) fields = super().get_field_names(declared_fields, info)

View File

@ -314,8 +314,10 @@ def get_push_system_user_tasks(system_user):
if system_user.username == "root": if system_user.username == "root":
return [] return []
tasks = [ tasks = []
{
if system_user.password:
tasks.append({
'name': 'Add user {}'.format(system_user.username), 'name': 'Add user {}'.format(system_user.username),
'action': { 'action': {
'module': 'user', 'module': 'user',
@ -324,8 +326,9 @@ def get_push_system_user_tasks(system_user):
encrypt_password(system_user.password, salt="K3mIlKK"), encrypt_password(system_user.password, salt="K3mIlKK"),
), ),
} }
}, })
{ if system_user.public_key:
tasks.append({
'name': 'Set {} authorized key'.format(system_user.username), 'name': 'Set {} authorized key'.format(system_user.username),
'action': { 'action': {
'module': 'authorized_key', 'module': 'authorized_key',
@ -333,8 +336,9 @@ def get_push_system_user_tasks(system_user):
system_user.username, system_user.public_key system_user.username, system_user.public_key
) )
} }
}, })
{ if system_user.sudo:
tasks.append({
'name': 'Set {} sudo setting'.format(system_user.username), 'name': 'Set {} sudo setting'.format(system_user.username),
'action': { 'action': {
'module': 'lineinfile', 'module': 'lineinfile',
@ -345,8 +349,7 @@ def get_push_system_user_tasks(system_user):
system_user.sudo, system_user.sudo,
) )
} }
} })
]
return tasks return tasks

View File

@ -50,7 +50,6 @@
<th>{% trans 'Hostname' %}</th> <th>{% trans 'Hostname' %}</th>
<th>{% trans 'IP' %}</th> <th>{% trans 'IP' %}</th>
<th>{% trans 'Port' %}</th> <th>{% trans 'Port' %}</th>
<th>{% trans 'Type' %}</th>
<th>{% trans 'Alive' %}</th> <th>{% trans 'Alive' %}</th>
<th>{% trans 'Action' %}</th> <th>{% trans 'Action' %}</th>
</tr> </tr>
@ -166,22 +165,23 @@ function initTable() {
var detail_btn = '<a href="{% url "assets:asset-detail" pk=DEFAULT_PK %}" data-aid="'+rowData.id+'">' + cellData + '</a>'; var detail_btn = '<a href="{% url "assets:asset-detail" pk=DEFAULT_PK %}" data-aid="'+rowData.id+'">' + cellData + '</a>';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id)); $(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}}, }},
{targets: 4, createdCell: function (td, cellData) { {targets: 3, createdCell: function (td, cellData) {
if (!cellData) { if (!cellData) {
$(td).html('<i class="fa fa-times text-danger"></i>') $(td).html('<i class="fa fa-times text-danger"></i>')
} else { } else {
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')
} }
}}, }},
{targets: 5, createdCell: function (td, cellData, rowData) { {targets: 4, createdCell: function (td, cellData, rowData) {
var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id); var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id);
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn-leave-group" data-aid="{{ DEFAULT_PK }}">{% trans "Remove" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id); var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn-leave-group" data-aid="{{ DEFAULT_PK }}">{% trans "Remove" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id);
$(td).html(update_btn + del_btn) $(td).html(update_btn + del_btn)
}} }}
], ],
ajax_url: '{% url "api-assets:asset-list" %}?asset_group_id={{ asset_group.id }}', ajax_url: '{% url "api-assets:asset-list" %}?asset_group_id={{ asset_group.id }}',
columns: [{data: "hostname" }, {data: "ip" }, {data: "port" }, columns: [
{data: "get_type_display" }, {data: "is_connective" }, {data: "id"}], {data: "hostname" }, {data: "ip" }, {data: "port" },
{data: "is_connective" }, {data: "id"}],
op_html: $('#actions').html() op_html: $('#actions').html()
}; };
jumpserver.initServerSideDataTable(options); jumpserver.initServerSideDataTable(options);

View File

@ -51,7 +51,6 @@
<th>{% trans 'Hostname' %}</th> <th>{% trans 'Hostname' %}</th>
<th>{% trans 'IP' %}</th> <th>{% trans 'IP' %}</th>
<th>{% trans 'Port' %}</th> <th>{% trans 'Port' %}</th>
<th>{% trans 'Type' %}</th>
<th>{% trans 'Alive' %}</th> <th>{% trans 'Alive' %}</th>
<th>{% trans 'Action' %}</th> <th>{% trans 'Action' %}</th>
</tr> </tr>
@ -159,21 +158,22 @@ function initTable() {
var detail_btn = '<a href="{% url "assets:asset-detail" pk=DEFAULT_PK %}" data-aid="'+rowData.id+'">' + cellData + '</a>'; var detail_btn = '<a href="{% url "assets:asset-detail" pk=DEFAULT_PK %}" data-aid="'+rowData.id+'">' + cellData + '</a>';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id)); $(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}}, }},
{targets: 4, createdCell: function (td, cellData) { {targets: 3, createdCell: function (td, cellData) {
if (!cellData) { if (!cellData) {
$(td).html('<i class="fa fa-times text-danger"></i>') $(td).html('<i class="fa fa-times text-danger"></i>')
} else { } else {
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')
} }
}}, }},
{targets: 5, createdCell: function (td, cellData, rowData) { {targets: 4, createdCell: function (td, cellData, rowData) {
var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id); var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', rowData.id);
$(td).html(update_btn) $(td).html(update_btn)
}} }}
], ],
ajax_url: '{% url "api-assets:asset-list" %}?cluster_id={{ cluster.id }}', ajax_url: '{% url "api-assets:asset-list" %}?cluster_id={{ cluster.id }}',
columns: [{data: "hostname" }, {data: "ip" }, {data: "port" }, columns: [
{data: "get_type_display" }, {data: "is_connective" }, {data: "id"}], {data: "hostname" }, {data: "ip" }, {data: "port" },
{data: "is_connective" }, {data: "id"}],
op_html: $('#actions').html() op_html: $('#actions').html()
}; };
jumpserver.initServerSideDataTable(options); jumpserver.initServerSideDataTable(options);

View File

@ -19,8 +19,6 @@
<th class="text-center">{% trans 'Hostname' %}</th> <th class="text-center">{% trans 'Hostname' %}</th>
<th class="text-center">{% trans 'IP' %}</th> <th class="text-center">{% trans 'IP' %}</th>
<th class="text-center">{% trans 'Port' %}</th> <th class="text-center">{% trans 'Port' %}</th>
<th class="text-center">{% trans 'Type' %}</th>
<th class="text-center">{% trans 'Env' %}</th>
<th class="text-center">{% trans 'Hardware' %}</th> <th class="text-center">{% trans 'Hardware' %}</th>
<th class="text-center">{% trans 'Active' %}</th> <th class="text-center">{% trans 'Active' %}</th>
<th class="text-center">{% trans 'Connective' %}</th> <th class="text-center">{% trans 'Connective' %}</th>
@ -44,14 +42,14 @@ function initTable() {
var detail_btn = '<a href="{{ the_url }}">' + cellData + '</a>'; var detail_btn = '<a href="{{ the_url }}">' + cellData + '</a>';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id)); $(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}}, }},
{targets: 7, createdCell: function (td, cellData) { {targets: 5, createdCell: function (td, cellData) {
if (!cellData) { if (!cellData) {
$(td).html('<i class="fa fa-times text-danger"></i>') $(td).html('<i class="fa fa-times text-danger"></i>')
} else { } else {
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')
} }
}}, }},
{targets: 8, createdCell: function (td, cellData) { {targets: 6, createdCell: function (td, cellData) {
if (cellData == 'Unknown'){ if (cellData == 'Unknown'){
$(td).html('<i class="fa fa-circle text-warning"></i>') $(td).html('<i class="fa fa-circle text-warning"></i>')
} else if (!cellData) { } else if (!cellData) {
@ -68,8 +66,7 @@ function initTable() {
ajax_url: '{% url "api-assets:user-asset-list" %}', ajax_url: '{% url "api-assets:user-asset-list" %}',
columns: [ columns: [
{data: "id"}, {data: "hostname" }, {data: "ip" }, {data: "port" }, {data: "id"}, {data: "hostname" }, {data: "ip" }, {data: "port" },
{data: "get_type_display" }, {data: "get_env_display"}, {data: "hardware_info"}, {data: "hardware_info"}, {data: "is_active" }, {data: "is_connective"}
{data: "is_active" }, {data: "is_connective"}
], ],
op_html: $('#actions').html() op_html: $('#actions').html()
}; };

View File

@ -88,7 +88,7 @@ class LDAPTestingAPI(APIView):
user[attr] = getattr(entry, mapping) user[attr] = getattr(entry, mapping)
users.append(user) users.append(user)
if len(users) > 0: if len(users) > 0:
return Response({"msg": "Match {} s users".format(len(users))}) return Response({"msg": _("Match {} s users").format(len(users))})
else: else:
return Response({"error": "Have user but attr mapping error"}, status=401) return Response({"error": "Have user but attr mapping error"}, status=401)
else: else:

View File

@ -117,7 +117,8 @@ class LDAPSettingForm(BaseForm):
label=_("User OU"), initial='ou=tech,dc=jumpserver,dc=org' label=_("User OU"), initial='ou=tech,dc=jumpserver,dc=org'
) )
AUTH_LDAP_SEARCH_FILTER = forms.CharField( AUTH_LDAP_SEARCH_FILTER = forms.CharField(
label=_("User search filter"), initial='(cn=%(user)s)' label=_("User search filter"), initial='(cn=%(user)s)',
help_text=_("User search filter must contain ([cn,uid,sAMAccountName,...]=%(user)s)")
) )
AUTH_LDAP_USER_ATTR_MAP = DictField( AUTH_LDAP_USER_ATTR_MAP = DictField(
label=_("User attr map"), label=_("User attr map"),
@ -125,13 +126,15 @@ class LDAPSettingForm(BaseForm):
"username": "cn", "username": "cn",
"name": "sn", "name": "sn",
"email": "mail" "email": "mail"
}) }),
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_OU = CONFIG.AUTH_LDAP_GROUP_SEARCH_OU
# AUTH_LDAP_GROUP_SEARCH_FILTER = CONFIG.AUTH_LDAP_GROUP_SEARCH_FILTER # AUTH_LDAP_GROUP_SEARCH_FILTER = CONFIG.AUTH_LDAP_GROUP_SEARCH_FILTER
AUTH_LDAP_START_TLS = forms.BooleanField( AUTH_LDAP_START_TLS = forms.BooleanField(
label=_("Use SSL"), initial=False, required=False label=_("Use SSL"), initial=False, required=False
) )
AUTH_LDAP = forms.BooleanField(label=_("Enable LDAP auth"), initial=False)
class TerminalSettingForm(BaseForm): class TerminalSettingForm(BaseForm):

Binary file not shown.

File diff suppressed because it is too large Load Diff