mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-09 03:16:25 +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__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(EditBuildingForm, self).__init__(*args, prefix=prefix, **kwargs)
|
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):
|
class EditPortProfileForm(FormRevMixin, ModelForm):
|
||||||
"""Form to edit a port profile"""
|
"""Form to edit a port profile"""
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -297,18 +269,3 @@ class EditPortProfileForm(FormRevMixin, ModelForm):
|
||||||
prefix=prefix,
|
prefix=prefix,
|
||||||
**kwargs)
|
**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(
|
radius_type = models.CharField(
|
||||||
max_length=32,
|
max_length=32,
|
||||||
choices=TYPES,
|
choices=TYPES,
|
||||||
|
help_text="Choix du type d'authentification radius : non actif, mac ou 802.1X",
|
||||||
verbose_name=_("RADIUS type")
|
verbose_name=_("RADIUS type")
|
||||||
)
|
)
|
||||||
radius_mode = models.CharField(
|
radius_mode = models.CharField(
|
||||||
max_length=32,
|
max_length=32,
|
||||||
choices=MODES,
|
choices=MODES,
|
||||||
default='COMMON',
|
default='COMMON',
|
||||||
|
help_text="En cas d'auth par mac, auth common ou strcit sur le port",
|
||||||
verbose_name=_("RADIUS mode")
|
verbose_name=_("RADIUS mode")
|
||||||
)
|
)
|
||||||
speed = models.CharField(
|
speed = models.CharField(
|
||||||
|
@ -605,6 +607,12 @@ class PortProfile(AclMixin, RevMixin, models.Model):
|
||||||
verbose_name = _("Port profile")
|
verbose_name = _("Port profile")
|
||||||
verbose_name_plural = _("Port profiles")
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -9,53 +9,34 @@
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Name" %}</th>
|
<th>{% trans "Nom" %}</th>
|
||||||
<th></td>
|
<th>{% trans "Default pour" %}</th>
|
||||||
<th>{% trans "VLAN untagged" %}</th>
|
<th>{% trans "VLANs" %}</th>
|
||||||
<td></td>
|
<th>{% trans "Réglages RADIUS" %}</th>
|
||||||
<th>{% trans "VLAN(s) tagged" %}</th>
|
<th>{% trans "Vitesse" %}</th>
|
||||||
<tr></tr>
|
<th>{% trans "Mac address limit" %}</th>
|
||||||
</tr>
|
<th>{% trans "Sécurité" %}</th>
|
||||||
<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></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for port_profile in port_profile_list %}
|
{% for port_profile in port_profile_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{port_profile.name}}</td>
|
<td>{{port_profile.name}}</td>
|
||||||
<td>{{port_profile.vlan_untagged}}</td>
|
<td>{{port_profile.profil_default}}</td>
|
||||||
<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>
|
||||||
<td>{{port_profile.radius_type}}</td>
|
<td>
|
||||||
<td>{{port_profile.radius_mode}}</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">
|
<td class="text-right">
|
||||||
{% include 'buttons/history.html' with href='topologie:history' name='portprofile' id=port_profile.pk %}
|
{% include 'buttons/history.html' with href='topologie:history' name='portprofile' id=port_profile.pk %}
|
||||||
{% can_edit port_profile %}
|
{% can_edit port_profile %}
|
||||||
|
|
|
@ -97,7 +97,6 @@ from .forms import (
|
||||||
EditAccessPointForm,
|
EditAccessPointForm,
|
||||||
EditSwitchBayForm,
|
EditSwitchBayForm,
|
||||||
EditBuildingForm,
|
EditBuildingForm,
|
||||||
NewPortProfileForm,
|
|
||||||
EditPortProfileForm,
|
EditPortProfileForm,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ def index(request):
|
||||||
switch_list = re2o_paginator(request, switch_list, pagination_number)
|
switch_list = re2o_paginator(request, switch_list, pagination_number)
|
||||||
port_profile_list = re2o_paginator(request, port_profile_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()
|
make_machine_graph()
|
||||||
for service_link in Service_link.objects.filter(service__service_type='graph_topo'):
|
for service_link in Service_link.objects.filter(service__service_type='graph_topo'):
|
||||||
service_link.done_regen()
|
service_link.done_regen()
|
||||||
|
@ -967,7 +966,7 @@ def del_constructor_switch(request, constructor_switch, **_kwargs):
|
||||||
@can_create(PortProfile)
|
@can_create(PortProfile)
|
||||||
def new_port_profile(request):
|
def new_port_profile(request):
|
||||||
"""Create a new port profile"""
|
"""Create a new port profile"""
|
||||||
port_profile = NewPortProfileForm(request.POST or None)
|
port_profile = EditPortProfileForm(request.POST or None)
|
||||||
if port_profile.is_valid():
|
if port_profile.is_valid():
|
||||||
port_profile.save()
|
port_profile.save()
|
||||||
messages.success(request, _("Port profile created"))
|
messages.success(request, _("Port profile created"))
|
||||||
|
|
Loading…
Reference in a new issue