mirror of https://gitlab.federez.net/re2o/re2o
committed by
chirac
7 changed files with 324 additions and 32 deletions
@ -0,0 +1,91 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-10-13 14:29 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
import re2o.mixins |
|||
|
|||
|
|||
def create_radius_policy(apps, schema_editor): |
|||
OptionalTopologie = apps.get_model('preferences', 'OptionalTopologie') |
|||
RadiusOption = apps.get_model('preferences', 'RadiusOption') |
|||
RadiusPolicy = apps.get_model('preferences', 'RadiusPolicy') |
|||
|
|||
option,_ = OptionalTopologie.objects.get_or_create() |
|||
|
|||
radius_option = RadiusOption() |
|||
radius_option.radius_general_policy = option.radius_general_policy |
|||
radius_option.unknown_machine = RadiusPolicy.objects.create() |
|||
radius_option.unknown_port = RadiusPolicy.objects.create() |
|||
radius_option.unknown_room = RadiusPolicy.objects.create() |
|||
radius_option.non_member = RadiusPolicy.objects.create() |
|||
radius_option.banned = RadiusPolicy.objects.create() |
|||
radius_option.vlan_decision_ok = option.vlan_decision_ok |
|||
|
|||
radius_option.save() |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0095_auto_20180919_2225'), |
|||
('preferences', '0051_auto_20180919_2225'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='RadiusOption', |
|||
fields=[ |
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('radius_general_policy', models.CharField(choices=[('MACHINE', "On the IP range's VLAN of the machine"), ('DEFINED', "Preset in 'VLAN for machines accepted by RADIUS'")], default='DEFINED', max_length=32)), |
|||
], |
|||
options={ |
|||
'verbose_name': 'radius policies', |
|||
}, |
|||
bases=(re2o.mixins.AclMixin, models.Model), |
|||
), |
|||
migrations.CreateModel( |
|||
name='RadiusPolicy', |
|||
fields=[ |
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('policy', models.CharField(choices=[('REJECT', 'Reject the machine'), ('SET_VLAN', 'Place the machine on the VLAN')], default='REJECT', max_length=32)), |
|||
('vlan', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='machines.Vlan')), |
|||
], |
|||
options={ |
|||
'verbose_name': 'radius policy', |
|||
}, |
|||
bases=(re2o.mixins.AclMixin, models.Model), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='non_member', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='non_member_option', to='preferences.RadiusPolicy', verbose_name='Policy non member users.'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='unknown_machine', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='unknown_machine_option', to='preferences.RadiusPolicy', verbose_name='Policy for unknown machines'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='unknown_port', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='unknown_port_option', to='preferences.RadiusPolicy', verbose_name='Policy for unknown machines'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='unknown_room', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='unknown_room_option', to='preferences.RadiusPolicy', verbose_name='Policy for machine connecting from unregistered room (relevant on ports with STRICT radius mode)'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='banned', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='banned_option', to='preferences.RadiusPolicy', verbose_name='Policy for banned users.'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='radiusoption', |
|||
name='vlan_decision_ok', |
|||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlan_ok_option', to='machines.Vlan'), |
|||
), |
|||
migrations.RunPython(create_radius_policy), |
|||
] |
|||
@ -0,0 +1,96 @@ |
|||
{% 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 Hugo Levy-Falk |
|||
|
|||
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 i18n %} |
|||
{% load acl %} |
|||
{% load logs_extra %} |
|||
|
|||
<table> |
|||
<tr> |
|||
<th>{% trans "General policy for VLAN setting" %}</th> |
|||
<td>{{ radiusoptions.radius_general_policy }}</td> |
|||
<td>{% trans "This setting defines the VLAN policy after acceptance by RADIUS: either on the IP range's VLAN of the machine, or a VLAN preset in 'VLAN for machines accepted by RADIUS'" %}</td> |
|||
</tr> |
|||
<tr> |
|||
<th>{% trans "VLAN for machines accepted by RADIUS" %}</th> |
|||
<td>{{ radiusoptions.vlan_decision_ok }}</td> |
|||
</tr> |
|||
</table> |
|||
<hr/> |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>{% trans "Situation" %}</th> |
|||
<th>{% trans "Behavior" %}</th> |
|||
</tr> |
|||
</thead> |
|||
<tr> |
|||
<th>{% trans "Unknown machine" %}</th> |
|||
<td> |
|||
{% if radiusoptions.unknown_machine.policy == 'REJECT' %} |
|||
<span class="label label-danger">{% trans "Reject" %}</span> |
|||
{% else %} |
|||
<span class="label label-success">Vlan {{ radiusoptions.unknown_machine.vlan }}</span> |
|||
{% endif %} |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th>{% trans "Unknown port" %}</th> |
|||
<td> |
|||
{% if radiusoptions.unknown_port.policy == 'REJECT' %} |
|||
<span class="label label-danger">{% trans "Reject" %}</span> |
|||
{% else %} |
|||
<span class="label label-success">Vlan {{ radiusoptions.unknown_port.vlan }}</span> |
|||
{% endif %} |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th>{% trans "Unknown room" %}</th> |
|||
<td> |
|||
{% if radiusoptions.unknown_room.policy == 'REJECT' %} |
|||
<span class="label label-danger">{% trans "Reject" %}</span> |
|||
{% else %} |
|||
<span class="label label-success">Vlan {{ radiusoptions.unknown_room.vlan }}</span> |
|||
{% endif %} |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th>{% trans "Non member" %}</th> |
|||
<td> |
|||
{% if radiusoptions.non_member.policy == 'REJECT' %} |
|||
<span class="label label-danger">{% trans "Reject" %}</span> |
|||
{% else %} |
|||
<span class="label label-success">Vlan {{ radiusoptions.non_member.vlan }}</span> |
|||
{% endif %} |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th>{% trans "Banned user" %}</th> |
|||
<td> |
|||
{% if radiusoptions.unknown_port.policy == 'REJECT' %} |
|||
<span class="label label-danger">{% trans "Reject" %}</span> |
|||
{% else %} |
|||
<span class="label label-success">Vlan {{ radiusoptions.banned.vlan }}</span> |
|||
{% endif %} |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
Loading…
Reference in new issue