Implement custom SSIDs and WPA2-PSK encryption

This commit is contained in:
Kumi 2019-03-08 15:16:37 +00:00
parent 1c69a1ebaa
commit 50cf4d5634
10 changed files with 98 additions and 5 deletions

View file

@ -24,7 +24,8 @@ config wifi-device 'radio1'
config wifi-iface
option device 'radio1'
option mode 'ap'
option encryption 'none'
option ssid '$SSID'
option encryption '$ENC'
option key '$KEY'
option network 'VPN360'

View file

@ -14,7 +14,8 @@ config wifi-iface 'default_radio0'
option device 'radio0'
option network 'VPN360'
option mode 'ap'
option encryption 'none'
option encryption '$ENC'
option key '$KEY'
option ifname 'wlan0'
option ssid '$SSID'

View file

@ -0,0 +1,28 @@
# Generated by Django 2.1.5 on 2019-03-08 13:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0048_auto_20190219_1521'),
]
operations = [
migrations.AddField(
model_name='model',
name='key',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='Broadcast WPA2 Key'),
),
migrations.AddField(
model_name='model',
name='ssid',
field=models.CharField(blank=True, max_length=32, null=True, verbose_name='Broadcast SSID'),
),
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -0,0 +1,36 @@
# Generated by Django 2.1.5 on 2019-03-08 13:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0049_auto_20190308_1334'),
]
operations = [
migrations.RemoveField(
model_name='model',
name='key',
),
migrations.RemoveField(
model_name='model',
name='ssid',
),
migrations.AddField(
model_name='device',
name='key',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='Broadcast WPA2 Key'),
),
migrations.AddField(
model_name='device',
name='ssid',
field=models.CharField(blank=True, max_length=32, null=True, verbose_name='Broadcast SSID'),
),
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -63,9 +63,11 @@ class Device(models.Model):
reboot = models.BooleanField("Trigger Reboot", default=False)
changed = models.DateTimeField("Last Change of Device Config", auto_now_add=True)
wireless = models.DateTimeField("Last Update of Wireless Config", blank=True, null=True, editable=False)
ssid = models.CharField("Broadcast SSID", max_length=32, blank=True, null=True)
key = models.CharField("Broadcast WPA2 Key", max_length=64, blank=True, null=True)
def __str__(self):
return "%s%s" % (self.serial, " (%s)" % self.curip if self.curip else "")
return "%s%s" % (self.serial, " (%s)" % self.ssid if self.ssid else "")
class DeviceLog(models.Model):
ADD = 0

View file

@ -53,7 +53,9 @@ def mkfirmware(device, path):
wirein = wireless.read()
with open(tempdir.name + "/etc/config/wireless", "w") as wireout:
wire = wirein.replace("$SSID", device.serial)
wire = wirein.replace("$SSID", device.ssid or device.serial)
wire = wire.replace("$KEY", device.key or "")
wire = wire.replace("$ENC", "psk2" if device.key else "none")
wireout.write(wire + "\n" + makewificonfig(device))
# Create compilation environment

View file

@ -478,6 +478,8 @@ def makedevice(request):
device_name = request.POST.get("name", "")
device_organization = request.POST.get("organization", "")
device_model = request.POST.get("model", "")
device_ssid = request.POST.get("ssid", device_serial)
device_key = request.POST.get("key", "")
if not device_serial:
orga = Organization.objects.all()
@ -515,6 +517,8 @@ def makedevice(request):
device = Device.objects.create(
serial=device_serial,
name=device_name,
ssid=device_ssid,
key=device_key,
model=Model.objects.filter(id=device_model)[0],
network=Network.objects.filter(intip="No VPN")[0],
organization=Organization.objects.filter(id=device_organization)[0],

View file

@ -12,6 +12,14 @@
<label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)"></input>
</div>
<div class="form-group">
<label for="ssid">Broadcast SSID</label>
<input type="text" class="form-control" name="ssid" id="ssid" placeholder="SSID to send, if different from Serial"></input>
</div>
<div class="form-group">
<label for="key">WPA2 Key</label>
<input type="text" class="form-control" name="key" id="key" value="exp360wifi" placeholder="WPA2 key if using encryption"></input>
</div>
<div class="form-group">
<label for="organization">Organization</label>
<select required class="custom-select mr-sm-2" id="organization" name="organization">

View file

@ -30,6 +30,16 @@
<label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)" {% if device.name %} value="{{ device.name }}" {% endif %}></input>
</div>
{% if user.is_staff %}
<div class="form-group">
<label for="ssid">Broadcast SSID</label>
<input type="text" class="form-control" name="ssid" id="ssid" {% if device.ssid %} value="{{ device.ssid }}" {% endif %} placeholder="SSID to send, if different from Serial"></input>
</div>
<div class="form-group">
<label for="key">WPA2 Key</label>
<input type="text" class="form-control" name="key" id="key" {% if device.key %} value="{{ device.key }}" {% endif %} placeholder="WPA2 key if using encryption"></input>
</div>
{% endif %}
<div class="form-group">
<label for="subnet">Assigned Network</label>
<select class="custom-select mr-sm-2" id="subnet" name="subnet">

View file

@ -18,7 +18,8 @@
<p><img src="{{ QR_URL }}" alt="QR Code" /></p>
{% elif wizard.steps.current == 'sms' %}
<p>{% blocktrans %}Please enter the phone number you wish to receive the
text messages on. This number will be validated in the next step.
text messages on. This number will be validated in the next step. Make
sure to use the international number format, e.g. +43800093004.
{% endblocktrans %}</p>
{% elif wizard.steps.current == 'call' %}
<p>{% blocktrans %}Please enter the phone number you wish to be called on.