mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-28 01:43:46 +00:00
Ajout reglages sécurité + frontend
This commit is contained in:
parent
860385bffe
commit
ad79c5b5e5
5 changed files with 55 additions and 85 deletions
|
@ -257,34 +257,6 @@ class EditBuildingForm(FormRevMixin, ModelForm):
|
|||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditBuildingForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
|
||||
class NewPortProfileForm(FormRevMixin, ModelForm):
|
||||
"""Form to create a port profile"""
|
||||
class Meta:
|
||||
model = PortProfile
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(NewPortProfileForm, self).__init__(*args,
|
||||
prefix=prefix,
|
||||
**kwargs)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(NewPortProfileForm, self).clean()
|
||||
radius_type = cleaned_data.get('radius_type')
|
||||
radius_mode = cleaned_data.get('radius_mode')
|
||||
|
||||
if radius_type == 'NO' and radius_mode:
|
||||
raise forms.ValidationError(_("You can't specify a RADIUS mode"
|
||||
" with RADIUS type NO"))
|
||||
elif radius_type != 'NO' and not radius_mode:
|
||||
raise forms.ValidationError(_("You have to specify a RADIUS"
|
||||
" mode"))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class EditPortProfileForm(FormRevMixin, ModelForm):
|
||||
"""Form to edit a port profile"""
|
||||
class Meta:
|
||||
|
@ -297,18 +269,3 @@ class EditPortProfileForm(FormRevMixin, ModelForm):
|
|||
prefix=prefix,
|
||||
**kwargs)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(EditPortProfileForm, self).clean()
|
||||
radius_type = cleaned_data.get('radius_type')
|
||||
radius_mode = cleaned_data.get('radius_mode')
|
||||
|
||||
if radius_type == 'NO' and radius_mode:
|
||||
raise forms.ValidationError(_("You can't specify a RADIUS mode"
|
||||
" with RADIUS type NO"))
|
||||
elif radius_type != 'NO' and not radius_mode:
|
||||
raise forms.ValidationError(_("You have to specify a RADIUS"
|
||||
" mode"))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
||||
|
|
25
topologie/migrations/0062_auto_20180627_0123.py
Normal file
25
topologie/migrations/0062_auto_20180627_0123.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-06-26 23:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('topologie', '0061_portprofile'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='portprofile',
|
||||
name='radius_mode',
|
||||
field=models.CharField(choices=[('STRICT', 'STRICT'), ('COMMON', 'COMMON')], default='COMMON', help_text="En cas d'auth par mac, auth common ou strcit sur le port", max_length=32, verbose_name='RADIUS mode'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='portprofile',
|
||||
name='radius_type',
|
||||
field=models.CharField(choices=[('NO', 'NO'), ('802.1X', '802.1X'), ('MAC-radius', 'MAC-radius')], help_text="Choix du type d'authentification radius : non actif, mac ou 802.1X", max_length=32, verbose_name='RADIUS type'),
|
||||
),
|
||||
]
|
|
@ -546,12 +546,14 @@ class PortProfile(AclMixin, RevMixin, models.Model):
|
|||
radius_type = models.CharField(
|
||||
max_length=32,
|
||||
choices=TYPES,
|
||||
help_text="Choix du type d'authentification radius : non actif, mac ou 802.1X",
|
||||
verbose_name=_("RADIUS type")
|
||||
)
|
||||
radius_mode = models.CharField(
|
||||
max_length=32,
|
||||
choices=MODES,
|
||||
default='COMMON',
|
||||
help_text="En cas d'auth par mac, auth common ou strcit sur le port",
|
||||
verbose_name=_("RADIUS mode")
|
||||
)
|
||||
speed = models.CharField(
|
||||
|
@ -605,6 +607,12 @@ class PortProfile(AclMixin, RevMixin, models.Model):
|
|||
verbose_name = _("Port profile")
|
||||
verbose_name_plural = _("Port profiles")
|
||||
|
||||
security_parameters_fields = ['loop_protect', 'ra_guard', 'arp_protect', 'dhcpv6_snooping', 'dhcp_snooping', 'flow_control']
|
||||
|
||||
@cached_property
|
||||
def security_parameters_enabled(self):
|
||||
return [parameter for parameter in self.security_parameters_fields if getattr(self, parameter)]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
|
@ -9,53 +9,34 @@
|
|||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th></td>
|
||||
<th>{% trans "VLAN untagged" %}</th>
|
||||
<td></td>
|
||||
<th>{% trans "VLAN(s) tagged" %}</th>
|
||||
<tr></tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "RADIUS type" %}</th>
|
||||
<td></td>
|
||||
<th>{% trans "RADIUS mode" %}</th>
|
||||
<th></th>
|
||||
<th>{% trans "RADIUS type" %}</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "speed" %}</th>
|
||||
<td></td>
|
||||
<th>{% trans "Mac limit" %}</th>
|
||||
<th></th>
|
||||
<th>{% trans "Flow control" %}</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "dhcp snooping" %}</th>
|
||||
<td></td>
|
||||
<th>{% trans "dhcpv6 snooping" %}</th>
|
||||
<th></th>
|
||||
<th>{% trans "arp protect" %}</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "ra guard" %}</th>
|
||||
<td></td>
|
||||
<th>{% trans "loop protect" %}</th>
|
||||
<th>{% trans "Nom" %}</th>
|
||||
<th>{% trans "Default pour" %}</th>
|
||||
<th>{% trans "VLANs" %}</th>
|
||||
<th>{% trans "Réglages RADIUS" %}</th>
|
||||
<th>{% trans "Vitesse" %}</th>
|
||||
<th>{% trans "Mac address limit" %}</th>
|
||||
<th>{% trans "Sécurité" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for port_profile in port_profile_list %}
|
||||
<tr>
|
||||
<td>{{port_profile.name}}</td>
|
||||
<td>{{port_profile.vlan_untagged}}</td>
|
||||
<td>{{port_profile.profil_default}}</td>
|
||||
<td>
|
||||
{{port_profile.vlan_tagged.all|join:", "}}
|
||||
<b>Untagged : </b>{{port_profile.vlan_untagged}}
|
||||
<br>
|
||||
<b>Tagged : </b>{{port_profile.vlan_tagged.all|join:", "}}
|
||||
</td>
|
||||
<td>{{port_profile.radius_type}}</td>
|
||||
<td>{{port_profile.radius_mode}}</td>
|
||||
<td>
|
||||
<b>Type : </b>{{port_profile.radius_type}}
|
||||
{% if port_profile.radius_type == "MAC-radius" %}
|
||||
<br>
|
||||
<b>Mode : </b>{{port_profile.radius_mode}}</td>
|
||||
{% endif %}
|
||||
<td>{{port_profile.speed}}</td>
|
||||
<td>{{port_profile.mac_limit}}</td>
|
||||
<td>{{port_profile.security_parameters_enabled|join:"<br>"}}</td>
|
||||
<td class="text-right">
|
||||
{% include 'buttons/history.html' with href='topologie:history' name='portprofile' id=port_profile.pk %}
|
||||
{% can_edit port_profile %}
|
||||
|
|
|
@ -97,7 +97,6 @@ from .forms import (
|
|||
EditAccessPointForm,
|
||||
EditSwitchBayForm,
|
||||
EditBuildingForm,
|
||||
NewPortProfileForm,
|
||||
EditPortProfileForm,
|
||||
)
|
||||
|
||||
|
@ -135,7 +134,7 @@ def index(request):
|
|||
switch_list = re2o_paginator(request, switch_list, pagination_number)
|
||||
port_profile_list = re2o_paginator(request, port_profile_list, pagination_number)
|
||||
|
||||
if any(service_link.need_regen() for service_link in Service_link.objects.filter(service__service_type='graph_topo')):
|
||||
if any(service_link.need_regen for service_link in Service_link.objects.filter(service__service_type='graph_topo')):
|
||||
make_machine_graph()
|
||||
for service_link in Service_link.objects.filter(service__service_type='graph_topo'):
|
||||
service_link.done_regen()
|
||||
|
@ -967,7 +966,7 @@ def del_constructor_switch(request, constructor_switch, **_kwargs):
|
|||
@can_create(PortProfile)
|
||||
def new_port_profile(request):
|
||||
"""Create a new port profile"""
|
||||
port_profile = NewPortProfileForm(request.POST or None)
|
||||
port_profile = EditPortProfileForm(request.POST or None)
|
||||
if port_profile.is_valid():
|
||||
port_profile.save()
|
||||
messages.success(request, _("Port profile created"))
|
||||
|
|
Loading…
Reference in a new issue