mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-29 16:12:26 +00:00
Gestion complete des algo de fingerprintssh
This commit is contained in:
parent
9c6d8d0ee5
commit
169ba8a9ff
8 changed files with 201 additions and 3 deletions
20
machines/migrations/0085_auto_20180623_1817.py
Normal file
20
machines/migrations/0085_auto_20180623_1817.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-06-23 16:17
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('machines', '0084_auto_20180623_1651'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sshfpralgo',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=256),
|
||||||
|
),
|
||||||
|
]
|
|
@ -235,7 +235,7 @@ class SshFprAlgo(RevMixin, AclMixin, models.Model):
|
||||||
"""Un aglorithme de création de la fingerprint ssh"""
|
"""Un aglorithme de création de la fingerprint ssh"""
|
||||||
PRETTY_NAME = "Algo de clef ssh"
|
PRETTY_NAME = "Algo de clef ssh"
|
||||||
|
|
||||||
name = models.TextField(max_length=256)
|
name = models.CharField(max_length=256)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = (
|
permissions = (
|
||||||
|
|
47
machines/templates/machines/aff_sshfpralgo.html
Normal file
47
machines/templates/machines/aff_sshfpralgo.html
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{% comment %}
|
||||||
|
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||||
|
se veut agnostique au réseau considéré, de manière à être installable en
|
||||||
|
quelques clics.
|
||||||
|
|
||||||
|
Copyright © 2018 Gabriel Détraz
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load acl %}
|
||||||
|
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nom de l'algo</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for sshfpralgo in sshfpralgo_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ sshfpralgo.name }}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{% can_edit sshfpralgo %}
|
||||||
|
{% include 'buttons/edit.html' with href='machines:edit-sshfpralgo' id=sshfpralgo.id %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% can_delete sshfpralgo %}
|
||||||
|
{% include 'buttons/suppr.html' with href='machines:del-sshfpralgo' id=sshfpralgo.id %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% include 'buttons/history.html' with href='machines:history' name='sshfpralgo' id=sshfpralgo.id %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
39
machines/templates/machines/index_sshfpralgo.html
Normal file
39
machines/templates/machines/index_sshfpralgo.html
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{% extends "machines/sidebar.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||||
|
se veut agnostique au réseau considéré, de manière à être installable en
|
||||||
|
quelques clics.
|
||||||
|
|
||||||
|
Copyright © 2018 Gabriel Détraz
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
{% load acl %}
|
||||||
|
|
||||||
|
{% block title %}Machines{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Liste des algo fingerprint ssh</h2>
|
||||||
|
{% can_create SshFprAlgo %}
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-sshfpralgo' %}"><i class="fa fa-plus"></i> Ajouter un algo ssh</a>
|
||||||
|
{% acl_end %}
|
||||||
|
{% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -78,6 +78,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% if sshfingerprintform %}
|
{% if sshfingerprintform %}
|
||||||
{% bootstrap_form_errors sshfingerprintform %}
|
{% bootstrap_form_errors sshfingerprintform %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if sshfpralgoform %}
|
||||||
|
{% bootstrap_form_errors sshfpralgoform %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +159,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<h3>SshFingerprint</h3>
|
<h3>SshFingerprint</h3>
|
||||||
{% bootstrap_form sshfingerprintform %}
|
{% bootstrap_form sshfingerprintform %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if sshfpralgoform %}
|
||||||
|
<h3>Algorithme de fingerprint ssh</h3>
|
||||||
|
{% bootstrap_form sshfpralgoform %}
|
||||||
|
{% endif %}
|
||||||
{% bootstrap_button action_name button_type="submit" icon="star" %}
|
{% bootstrap_button action_name button_type="submit" icon="star" %}
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -44,6 +44,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
Extensions et zones
|
Extensions et zones
|
||||||
</a>
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
|
{% can_view_all SshFprAlgo %}
|
||||||
|
<a class="list-group-item list-group-item-info" href="{% url "machines:index-sshfpralgo" %}">
|
||||||
|
<i class="fa fa-list-ul"></i>
|
||||||
|
Algo de fingerprint ssh
|
||||||
|
</a>
|
||||||
|
{% acl_end %}
|
||||||
{% can_view_all IpType %}
|
{% can_view_all IpType %}
|
||||||
<a class="list-group-item list-group-item-info" href="{% url "machines:index-iptype" %}">
|
<a class="list-group-item list-group-item-info" href="{% url "machines:index-iptype" %}">
|
||||||
<i class="fa fa-list-ul"></i>
|
<i class="fa fa-list-ul"></i>
|
||||||
|
|
|
@ -117,6 +117,18 @@ urlpatterns = [
|
||||||
url(r'^index_sshfingerprint/(?P<machineid>[0-9]+)$',
|
url(r'^index_sshfingerprint/(?P<machineid>[0-9]+)$',
|
||||||
views.index_sshfingerprint,
|
views.index_sshfingerprint,
|
||||||
name='index-sshfingerprint'),
|
name='index-sshfingerprint'),
|
||||||
|
url(r'^new_sshfpralgo/$',
|
||||||
|
views.new_sshfpralgo,
|
||||||
|
name='new-sshfpralgo'),
|
||||||
|
url(r'^edit_sshfpralgo/(?P<sshfpralgoid>[0-9]+)$',
|
||||||
|
views.edit_sshfpralgo,
|
||||||
|
name='edit-sshfpralgo'),
|
||||||
|
url(r'^del_sshfpralgo/(?P<sshfpralgoid>[0-9]+)$',
|
||||||
|
views.del_sshfpralgo,
|
||||||
|
name='del-sshfpralgo'),
|
||||||
|
url(r'^index_sshfpralgo/$',
|
||||||
|
views.index_sshfpralgo,
|
||||||
|
name='index-sshfpralgo'),
|
||||||
url(r'^add_service/$', views.add_service, name='add-service'),
|
url(r'^add_service/$', views.add_service, name='add-service'),
|
||||||
url(r'^edit_service/(?P<serviceid>[0-9]+)$',
|
url(r'^edit_service/(?P<serviceid>[0-9]+)$',
|
||||||
views.edit_service,
|
views.edit_service,
|
||||||
|
|
|
@ -475,7 +475,7 @@ def new_sshfingerprint(request, machine, **_kwargs):
|
||||||
messages.success(request, "Fingerprint ssh ajoutée")
|
messages.success(request, "Fingerprint ssh ajoutée")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'machines:index-sshfingerprint',
|
'machines:index-sshfingerprint',
|
||||||
kwargs={'machine': str(machine.id)}
|
kwargs={'machineid': str(machine.id)}
|
||||||
))
|
))
|
||||||
return form(
|
return form(
|
||||||
{'sshfingerprintform': sshfingerprint, 'action_name': 'Créer'},
|
{'sshfingerprintform': sshfingerprint, 'action_name': 'Créer'},
|
||||||
|
@ -495,7 +495,7 @@ def edit_sshfingerprint(request, sshfingerprint_instance, **_kwargs):
|
||||||
if sshfingerprint.is_valid():
|
if sshfingerprint.is_valid():
|
||||||
if sshfingerprint.changed_data:
|
if sshfingerprint.changed_data:
|
||||||
sshfingerprint.save()
|
sshfingerprint.save()
|
||||||
messages.success(request, "Ipv6 modifiée")
|
messages.success(request, "Ssh fingerprint modifiée")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'machines:index-sshfingerprint',
|
'machines:index-sshfingerprint',
|
||||||
kwargs={'machineid': str(sshfingerprint_instance.machine.id)}
|
kwargs={'machineid': str(sshfingerprint_instance.machine.id)}
|
||||||
|
@ -526,6 +526,72 @@ def del_sshfingerprint(request, sshfingerprint, **_kwargs):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_create(SshFprAlgo)
|
||||||
|
def new_sshfpralgo(request, **_kwargs):
|
||||||
|
"""Nouvelle sshfpralgo"""
|
||||||
|
sshfpralgo = SshFprAlgoForm(
|
||||||
|
request.POST or None,
|
||||||
|
)
|
||||||
|
if sshfpralgo.is_valid():
|
||||||
|
sshfpralgo.save()
|
||||||
|
messages.success(request, "Algo Fingerprint ssh ajouté")
|
||||||
|
return redirect(reverse(
|
||||||
|
'machines:index-sshfpralgo'
|
||||||
|
))
|
||||||
|
return form(
|
||||||
|
{'sshfpralgoform': sshfpralgo, 'action_name': 'Créer'},
|
||||||
|
'machines/machine.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_edit(SshFprAlgo)
|
||||||
|
def edit_sshfpralgo(request, sshfpralgo_instance, **_kwargs):
|
||||||
|
"""Edition d'une sshfpralgo"""
|
||||||
|
sshfpralgo = SshFprAlgoForm(
|
||||||
|
request.POST or None,
|
||||||
|
instance=sshfpralgo_instance
|
||||||
|
)
|
||||||
|
if sshfpralgo.is_valid():
|
||||||
|
if sshfpralgo.changed_data:
|
||||||
|
sshfpralgo.save()
|
||||||
|
messages.success(request, "Algo de sshfp modifiée")
|
||||||
|
return redirect(reverse(
|
||||||
|
'machines:index-sshfpralgo'
|
||||||
|
))
|
||||||
|
return form(
|
||||||
|
{'sshfpralgoform': sshfpralgo, 'action_name': 'Editer'},
|
||||||
|
'machines/machine.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_delete(SshFprAlgo)
|
||||||
|
def del_sshfpralgo(request, sshfpralgo, **_kwargs):
|
||||||
|
""" Supprime une sshfpralgo"""
|
||||||
|
if request.method == "POST":
|
||||||
|
try:
|
||||||
|
sshfpralgo.delete()
|
||||||
|
messages.success(request, "La sshfpralgo a été détruite")
|
||||||
|
except ProtectedError:
|
||||||
|
messages.error(
|
||||||
|
request,
|
||||||
|
("L'algo est affectée à au moins une fingerprint ssh, "
|
||||||
|
"vous ne pouvez pas le supprimer")
|
||||||
|
)
|
||||||
|
return redirect(reverse(
|
||||||
|
'machines:index-sshfpralgo'
|
||||||
|
))
|
||||||
|
return form(
|
||||||
|
{'objet': sshfpralgo, 'objet_name': 'sshfpralgo'},
|
||||||
|
'machines/delete.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(IpType)
|
@can_create(IpType)
|
||||||
def add_iptype(request):
|
def add_iptype(request):
|
||||||
|
|
Loading…
Reference in a new issue