Merge pull request #81 from jumpserver/v3.0_beta_issue_62

V3.0 beta issue 62 用户下载key后,就删除,为了安全
pull/94/head
ibuler 2016-02-25 13:15:13 +08:00
commit d0ba0503e5
2 changed files with 11 additions and 2 deletions

View File

@ -452,7 +452,6 @@ def down_key(request):
uuid_r = request.GET.get('uuid', '') uuid_r = request.GET.get('uuid', '')
else: else:
uuid_r = request.user.uuid uuid_r = request.user.uuid
if uuid_r: if uuid_r:
user = get_object(User, uuid=uuid_r) user = get_object(User, uuid=uuid_r)
if user: if user:
@ -465,6 +464,8 @@ def down_key(request):
f.close() f.close()
response = HttpResponse(data, content_type='application/octet-stream') response = HttpResponse(data, content_type='application/octet-stream')
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file) response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file)
if request.user.role == 'CU':
os.unlink(private_key_file)
return response return response
return HttpResponse('No Key File. Contact Admin.') return HttpResponse('No Key File. Contact Admin.')

View File

@ -70,7 +70,7 @@
{% if user.username|key_exist %} {% if user.username|key_exist %}
<a href="{% url 'key_down' %}?uuid={{ user.uuid }}" >下载</a> <a href="{% url 'key_down' %}?uuid={{ user.uuid }}" >下载</a>
{% else %} {% else %}
<span style="color: #586b7d">NoKey</span> <a href="#" onclick="genSSH('{{ user.username }}','{% url 'key_gen' %}?uuid={{ user.uuid }}')">NoKey GenOne?</a>
{% endif %} {% endif %}
</td> </td>
<td class="text-center"> <td class="text-center">
@ -150,5 +150,13 @@
}); });
$('.shiftCheckbox').shiftcheckbox(); $('.shiftCheckbox').shiftcheckbox();
}); });
function genSSH(username, url) {
if (confirm('Are you sure to gen a sshkey for user ' + username)) {
$.get(url, function (data) {
alert(data);
location.reload()
})
}
}
</script> </script>
{% endblock %} {% endblock %}