Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
fdf46d3
Create freeradius3.inc
mimugmail Jun 30, 2017
bfd5b0f
Create Makefile
mimugmail Jun 30, 2017
9deb431
Create pkg-descr
mimugmail Jun 30, 2017
dd12ac6
Create GeneralController.php
mimugmail Jun 30, 2017
442b73b
Create general.xml
mimugmail Jun 30, 2017
dc99043
Create ACL.xml
mimugmail Jun 30, 2017
05ecfe6
Create general.volt
mimugmail Jun 30, 2017
71dd525
Create setup.sh
mimugmail Jun 30, 2017
6c08d95
Create actions_freeradius3.conf
mimugmail Jun 30, 2017
5d6b464
Create +TARGETS
mimugmail Jun 30, 2017
b7b6b55
Create radiusd
mimugmail Jun 30, 2017
258615c
Update +TARGETS
mimugmail Jun 30, 2017
c6caf01
Create users
mimugmail Jun 30, 2017
3974f52
Create GeneralController.php
mimugmail Jun 30, 2017
cf16e21
Update general.xml
mimugmail Jun 30, 2017
dff32cd
Update GeneralController.php
mimugmail Jun 30, 2017
8cfabd4
Create ServiceController.php
mimugmail Jun 30, 2017
74383e9
Create General.xml
mimugmail Jun 30, 2017
f8eac25
Create General.php
mimugmail Jun 30, 2017
c160316
Create Menu.xml
mimugmail Jun 30, 2017
43e2ad3
Update ACL.xml
mimugmail Jun 30, 2017
286873f
Update general.volt
mimugmail Jun 30, 2017
e074965
Update general.volt
mimugmail Jun 30, 2017
35fe046
Update setup.sh
mimugmail Jun 30, 2017
20a5a30
Update actions_freeradius3.conf
mimugmail Jun 30, 2017
f9b5e6e
Update actions_freeradius3.conf
mimugmail Jun 30, 2017
40ece5c
Update ServiceController.php
mimugmail Jun 30, 2017
2c83d1c
Update pkg-descr
mimugmail Jun 30, 2017
426fa23
Update Menu.xml
mimugmail Jun 30, 2017
bd84f9e
Update Makefile
mimugmail Jun 30, 2017
b78e833
Update Makefile
mimugmail Jun 30, 2017
fe23da5
Update Makefile
mimugmail Jun 30, 2017
4f13502
removed the 3
mimugmail Jun 30, 2017
55208c4
Update and rename actions_freeradius3.conf to actions_freeradius.conf
mimugmail Jun 30, 2017
f5baf37
Rename net/freeradius3/opnsense/service/templates/OPNsense/Freeradius…
mimugmail Jun 30, 2017
f4cd15c
Update and rename net/freeradius3/opnsense/service/templates/OPNsense…
mimugmail Jun 30, 2017
968f758
Rename net/freeradius3/opnsense/scripts/Freeradius3/setup.sh to net/f…
mimugmail Jun 30, 2017
e200d26
Update and rename net/freeradius3/opnsense/mvc/app/controllers/OPNsen…
mimugmail Jun 30, 2017
b50c503
Update and rename net/freeradius3/opnsense/mvc/app/controllers/OPNsen…
mimugmail Jun 30, 2017
b93fea9
Update and rename net/freeradius3/opnsense/mvc/app/controllers/OPNsen…
mimugmail Jun 30, 2017
d85f5e1
Update and rename net/freeradius3/opnsense/mvc/app/controllers/OPNsen…
mimugmail Jun 30, 2017
59356a9
Update and rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Fr…
mimugmail Jun 30, 2017
5983b79
Update and rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Fr…
mimugmail Jun 30, 2017
49c8a0e
Update and rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Fr…
mimugmail Jun 30, 2017
762cb87
Update and rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Fr…
mimugmail Jun 30, 2017
9597f97
Update and rename net/freeradius3/opnsense/mvc/app/views/OPNsense/Fre…
mimugmail Jun 30, 2017
997fe19
Rename net/freeradius3/pkg-descr to net/freeradius/pkg-descr
mimugmail Jun 30, 2017
f9b82a5
Rename net/freeradius3/Makefile to net/freeradius/Makefile
mimugmail Jun 30, 2017
cb2a11d
Rename net/freeradius3/src/etc/inc/plugins.inc.d/freeradius.inc to ne…
mimugmail Jun 30, 2017
d388b70
Rename net/freeradius3/opnsense/service/templates/OPNsense/Freeradius…
mimugmail Jun 30, 2017
9337f69
Rename net/freeradius3/opnsense/service/templates/OPNsense/Freeradius…
mimugmail Jun 30, 2017
201ea57
Rename net/freeradius3/opnsense/service/templates/OPNsense/Freeradius…
mimugmail Jun 30, 2017
1877c3f
Rename net/freeradius3/opnsense/service/conf/actions.d/actions_freera…
mimugmail Jun 30, 2017
35a5c0a
Rename net/freeradius3/opnsense/scripts/Freeradius/setup.sh to net/fr…
mimugmail Jun 30, 2017
dc6af8a
Rename net/freeradius3/opnsense/mvc/app/controllers/OPNsense/Freeradi…
mimugmail Jun 30, 2017
38d5841
Rename net/freeradius3/opnsense/mvc/app/controllers/OPNsense/Freeradi…
mimugmail Jun 30, 2017
9bdeb20
Rename net/freeradius3/opnsense/mvc/app/controllers/OPNsense/Freeradi…
mimugmail Jun 30, 2017
fa9ce5c
Update and rename net/freeradius3/opnsense/mvc/app/controllers/OPNsen…
mimugmail Jun 30, 2017
6d365af
Rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Freeradius/Ge…
mimugmail Jun 30, 2017
35f8335
Rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Freeradius/Ge…
mimugmail Jun 30, 2017
45c7ad6
Rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Freeradius/Me…
mimugmail Jun 30, 2017
5713e90
Rename net/freeradius3/opnsense/mvc/app/models/OPNsense/Freeradius/AC…
mimugmail Jun 30, 2017
78d37f1
Rename net/freeradius3/opnsense/mvc/app/views/OPNsense/Freeradius/gen…
mimugmail Jun 30, 2017
eeabf95
Update ACL.xml
mimugmail Jun 30, 2017
9aa7a8b
Rename net/freeradius/opnsense/service/templates/OPNsense/Freeradius/…
mimugmail Jun 30, 2017
efb1445
Rename net/freeradius/opnsense/service/templates/OPNsense/Freeradius/…
mimugmail Jun 30, 2017
a0fd408
Rename net/freeradius/opnsense/service/templates/OPNsense/Freeradius/…
mimugmail Jun 30, 2017
4c00bb5
Rename net/freeradius/opnsense/service/conf/actions.d/actions_freerad…
mimugmail Jun 30, 2017
257361d
Rename net/freeradius/opnsense/scripts/Freeradius/setup.sh to net/fre…
mimugmail Jun 30, 2017
d0d5dec
Rename net/freeradius/opnsense/mvc/app/controllers/OPNsense/Freeradiu…
mimugmail Jun 30, 2017
b5270e7
Rename net/freeradius/opnsense/mvc/app/controllers/OPNsense/Freeradiu…
mimugmail Jun 30, 2017
dd7f8bd
Rename net/freeradius/opnsense/mvc/app/controllers/OPNsense/Freeradiu…
mimugmail Jun 30, 2017
0f6d620
Rename net/freeradius/opnsense/mvc/app/controllers/OPNsense/Freeradiu…
mimugmail Jun 30, 2017
a2d3df1
Rename net/freeradius/opnsense/mvc/app/models/OPNsense/Freeradius/ACL…
mimugmail Jun 30, 2017
cedde41
Rename net/freeradius/opnsense/mvc/app/models/OPNsense/Freeradius/Men…
mimugmail Jun 30, 2017
a83f93d
Rename net/freeradius/opnsense/mvc/app/models/OPNsense/Freeradius/Gen…
mimugmail Jun 30, 2017
0b4ef2a
Rename net/freeradius/opnsense/mvc/app/models/OPNsense/Freeradius/Gen…
mimugmail Jun 30, 2017
7e64bb7
Rename net/freeradius/opnsense/mvc/app/views/OPNsense/Freeradius/gene…
mimugmail Jun 30, 2017
2e27fb6
Rename GeneralController.ph to GeneralController.php
mimugmail Jun 30, 2017
8ed3d31
Create clients.conf
mimugmail Jun 30, 2017
39df406
Create dictionary
mimugmail Jun 30, 2017
f9169ad
Create hints
mimugmail Jun 30, 2017
ca40809
Create huntgroups
mimugmail Jun 30, 2017
25bd0f7
Update huntgroups
mimugmail Jun 30, 2017
e6c1c0f
Create proxy.conf
mimugmail Jun 30, 2017
a1d4c9d
Update proxy.conf
mimugmail Jun 30, 2017
b279194
Create radius.conf
mimugmail Jun 30, 2017
9d8c035
Create templates.conf
mimugmail Jun 30, 2017
be8abb3
Update templates.conf
mimugmail Jun 30, 2017
b51e1d3
Create trigger.conf
mimugmail Jun 30, 2017
85dd03a
Update users
mimugmail Jun 30, 2017
2aa67a0
Update users
mimugmail Jun 30, 2017
533253a
Create default
mimugmail Jun 30, 2017
3ece8b9
Create inner-tunnel
mimugmail Jun 30, 2017
e674146
Update inner-tunnel
mimugmail Jun 30, 2017
eee022b
Update +TARGETS
mimugmail Jun 30, 2017
2865536
Update +TARGETS
mimugmail Jun 30, 2017
33da1ab
Update +TARGETS
mimugmail Jun 30, 2017
8a7fcba
Rename net/freeradius/src/opnsense/service/templates/OPNsense/Freerad…
mimugmail Jun 30, 2017
9bf82d4
Rename net/freeradius/src/opnsense/service/templates/OPNsense/Freerad…
mimugmail Jun 30, 2017
e14fb7e
Update +TARGETS
mimugmail Jun 30, 2017
ce44d3d
Update radius.conf
mimugmail Jun 30, 2017
febc3e3
Update sites-enabled-default
mimugmail Jun 30, 2017
810ea23
Update sites-enabled-default
mimugmail Jun 30, 2017
7e1619c
Rename radius.conf to radiusd.conf
mimugmail Jun 30, 2017
ba1802d
Update +TARGETS
mimugmail Jun 30, 2017
fb121c4
Create UserController.php
mimugmail Jul 1, 2017
40051d3
Create user.xml
mimugmail Jul 1, 2017
b44401d
Update user.xml
mimugmail Jul 1, 2017
a9808e0
Create UserController.php
mimugmail Jul 1, 2017
d9ceba4
Create User.php
mimugmail Jul 1, 2017
b965ea8
Update User.php
mimugmail Jul 1, 2017
111e0fb
Create User.xml
mimugmail Jul 1, 2017
f2bef0e
Update UserController.php
mimugmail Jul 1, 2017
3d5a0dc
Create user.volt
mimugmail Jul 1, 2017
abe2992
Update Menu.xml
mimugmail Jul 1, 2017
b0e70a9
Update UserController.php
mimugmail Jul 1, 2017
86b5a8c
Rename user.xml to DialogEditFreeRADIUSUser.xml
mimugmail Jul 1, 2017
b4f4106
Update user.volt
mimugmail Jul 1, 2017
889858b
Update user.volt
mimugmail Jul 1, 2017
44cdce1
Update UserController.php
mimugmail Jul 1, 2017
f89b4d9
Update user.volt
mimugmail Jul 1, 2017
d8f9c1e
Rename DialogEditFreeRADIUSUser.xml to dialogEditFreeRADIUSUser.xml
mimugmail Jul 1, 2017
03be2ea
Update user.volt
mimugmail Jul 1, 2017
1e96a43
Update user.volt
mimugmail Jul 1, 2017
bcee9c2
Update user.volt
mimugmail Jul 1, 2017
0e3ce23
Rename user.volt to user_.volt
mimugmail Jul 2, 2017
809a709
Create user.volt
mimugmail Jul 2, 2017
be98e94
Delete user_.volt
mimugmail Jul 2, 2017
81568d3
Update user.volt
mimugmail Jul 2, 2017
449a084
Update User.xml
mimugmail Jul 2, 2017
978a343
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 2, 2017
383bd38
Update UserController.php
mimugmail Jul 2, 2017
73965bd
Update UserController.php
mimugmail Jul 2, 2017
bed7a4c
Update UserController.php
mimugmail Jul 2, 2017
26cfa11
Update UserController.php
mimugmail Jul 2, 2017
44d0489
Update user.volt
mimugmail Jul 2, 2017
ded3a67
Update user.volt
mimugmail Jul 2, 2017
231c64c
Update user.volt
mimugmail Jul 2, 2017
22834ac
Update UserController.php
mimugmail Jul 2, 2017
6c31e15
Update User.xml
mimugmail Jul 2, 2017
fd61f5a
Update UserController.php
mimugmail Jul 2, 2017
6d65fde
Update users
mimugmail Jul 3, 2017
3f8c5cc
Update users
mimugmail Jul 3, 2017
5686ee7
Update users
mimugmail Jul 3, 2017
cbcfd97
Update users
mimugmail Jul 3, 2017
0e84486
Update users
mimugmail Jul 3, 2017
57eb5f1
Update users
mimugmail Jul 3, 2017
a90b212
Update users
mimugmail Jul 3, 2017
8c23f42
Update users
mimugmail Jul 3, 2017
3b1d6b8
Update User.xml
mimugmail Jul 3, 2017
025a057
Update users
mimugmail Jul 3, 2017
07d81e4
Update users
mimugmail Jul 3, 2017
ba2a55c
Update users
mimugmail Jul 3, 2017
b5a26bb
Update users
mimugmail Jul 3, 2017
c0ebea9
Update users
mimugmail Jul 3, 2017
fd0efd3
Update users
mimugmail Jul 3, 2017
80afc0f
Update users
mimugmail Jul 3, 2017
81eaa15
Create ClientController.php
mimugmail Jul 3, 2017
b7906df
Update ClientController.php
mimugmail Jul 3, 2017
d839a5d
Create ClientController.php
mimugmail Jul 3, 2017
a14e675
Create dialogEditFreeRADIUSClient.xml
mimugmail Jul 3, 2017
5bc3127
Create Client.php
mimugmail Jul 3, 2017
227a474
Create Client.xml
mimugmail Jul 3, 2017
43b6af5
Update Menu.xml
mimugmail Jul 3, 2017
c4d9f75
Create client.volt
mimugmail Jul 3, 2017
b4f48e3
Update ClientController.php
mimugmail Jul 3, 2017
f75aace
Update client.volt
mimugmail Jul 3, 2017
c7f3f38
Update clients.conf
mimugmail Jul 3, 2017
5ba8fdb
Update clients.conf
mimugmail Jul 3, 2017
9ad80a8
Update clients.conf
mimugmail Jul 3, 2017
95238b7
bump to 0.2.0
mimugmail Jul 3, 2017
079a8f1
Delete dictionary
mimugmail Jul 3, 2017
6d1bb56
Delete hints
mimugmail Jul 3, 2017
669aada
Delete huntgroups
mimugmail Jul 3, 2017
ea19ef4
Delete proxy.conf
mimugmail Jul 3, 2017
49d8e4e
Delete templates.conf
mimugmail Jul 3, 2017
8b8052f
Delete trigger.conf
mimugmail Jul 3, 2017
e354da9
Update +TARGETS
mimugmail Jul 3, 2017
0a24527
Update +TARGETS
mimugmail Jul 3, 2017
4a0fe5d
Update users
mimugmail Jul 3, 2017
95f2b55
Update users
mimugmail Jul 3, 2017
6571de1
Update users
mimugmail Jul 3, 2017
1883da7
Update user.volt
mimugmail Jul 3, 2017
2dd0b78
Update User.xml
mimugmail Jul 3, 2017
be325a0
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 3, 2017
b13fdeb
Update UserController.php
mimugmail Jul 3, 2017
1e4ac93
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 3, 2017
1e450ae
Update users
mimugmail Jul 3, 2017
b930558
Update users
mimugmail Jul 3, 2017
a2d645b
Update users
mimugmail Jul 3, 2017
0ac217d
Update users
mimugmail Jul 3, 2017
5f78ed0
Update users
mimugmail Jul 3, 2017
4c269d2
Update users
mimugmail Jul 3, 2017
3687e75
Update users
mimugmail Jul 3, 2017
a0a4380
Update Menu.xml
mimugmail Jul 3, 2017
0c3269b
Update Menu.xml
mimugmail Jul 3, 2017
0b982e8
Update User.xml
mimugmail Jul 3, 2017
b3bb349
Update User.xml
mimugmail Jul 3, 2017
cb1840a
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 3, 2017
4f02df4
Update User.xml
mimugmail Jul 4, 2017
28f1ca5
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 4, 2017
0ba2c8f
Update User.xml
mimugmail Jul 4, 2017
3b11585
Update users
mimugmail Jul 5, 2017
8729c91
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 5, 2017
faf0b31
Update general.xml
mimugmail Jul 6, 2017
e6318e6
Update General.xml
mimugmail Jul 6, 2017
55ad2e1
Update +TARGETS
mimugmail Jul 6, 2017
48089ba
Create mods-enabled-eap
mimugmail Jul 6, 2017
3c7b55b
Update mods-enabled-eap
mimugmail Jul 6, 2017
f6af575
Update ClientController.php
mimugmail Jul 6, 2017
f3c958b
Update GeneralController.php
mimugmail Jul 6, 2017
2908362
Update UserController.php
mimugmail Jul 6, 2017
275018a
Added VLAN assignment and style fixes
mimugmail Jul 6, 2017
337d95c
Update freeradius.inc
mimugmail Jul 6, 2017
2c3f542
Update ClientController.php
mimugmail Jul 6, 2017
9fbe999
Update ClientController.php
mimugmail Jul 6, 2017
dba79f9
Update GeneralController.php
mimugmail Jul 6, 2017
1afdb5f
Update UserController.php
mimugmail Jul 6, 2017
72b67ad
Update dialogEditFreeRADIUSUser.xml
mimugmail Jul 6, 2017
11290f2
Update dialogEditFreeRADIUSClient.xml
mimugmail Jul 6, 2017
752396e
Update general.xml
mimugmail Jul 6, 2017
30dcec7
Update Menu.xml
mimugmail Jul 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions net/freeradius/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PLUGIN_NAME= freeradius
PLUGIN_VERSION= 0.3.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI: as long as the pull request is open you don't have to necessarily bump the version more than once. we also have PLUGIN_REVISION= which can be set to a numeric value for bugfixes, that's why most plugins only have X.Y, not X.Y.Z. But @fabianfrz likes three version numbers and that's perfectly fine here... only want to explain :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with both, let's keep it this way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok 👍

PLUGIN_COMMENT= RADIUS Authentication, Authorization and Accounting Server
PLUGIN_DEPENDS= freeradius3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also FYI, freeradius3 has been bumped to 3.0.14 in the ports tree two days ago

PLUGIN_MAINTAINER= m.muenz@gmail.com

.include "../../Mk/plugins.mk"
16 changes: 16 additions & 0 deletions net/freeradius/pkg-descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FreeRADIUS includes a RADIUS server, a BSD licensed client library,
a PAM library, and an Apache module. In most cases,
the word FreeRADIUS refers to the RADIUS server.

FreeRADIUS is the most widely deployed RADIUS server in the world.
It is the basis for multiple commercial offerings.
It supplies the AAA needs of many Fortune-500
companies and Tier 1 ISPs.

It is also widely used for Enterprise Wi-Fi and IEEE 802.1X
network security, particularly in the academic community,
including eduroam.

The server is fast, feature-rich, modular, and scalable.

WWW: http://www.freeradius.org
49 changes: 49 additions & 0 deletions net/freeradius/src/etc/inc/plugins.inc.d/freeradius.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
Copyright (C) 2017 Michael Muenz
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

function freeradius_services()
{
global $config;

$services = array();

if (isset($config['OPNsense']['freeradius']['general']['enabled']) && $config['OPNsense']['freeradius']['general']['enabled'] == 1) {
$services[] = array(
'description' => gettext('FreeRADIUS'),
'configd' => array(
'restart' => array('freeradius restart'),
'start' => array('freeradius start'),
'stop' => array('freeradius stop'),
),
'name' => 'freeradius',
'pidfile' => '/var/run/radiusd/radiusd.pid'
);
}

return $services;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<?php
/**
* Copyright (C) 2015 - 2017 Deciso B.V.
* Copyright (C) 2017 Michael Muenz
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

namespace OPNsense\Freeradius\Api;

use \OPNsense\Freeradius\Client;
use \OPNsense\Core\Config;
use \OPNsense\Base\ApiMutableModelControllerBase;
use \OPNsense\Base\UIModelGrid;

class ClientController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'Client';
static protected $internalModelClass = '\OPNsense\Freeradius\Client';
public function getAction()
{
// define list of configurable settings
$result = array();
if ($this->request->isGet()) {
$mdlClient = new Client();
$result['client'] = $mdlClient->getNodes();
}
return $result;
}

public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlClient = new Client();
$mdlClient->setNodes($this->request->getPost("client"));
// perform validation
$valMsgs = $mdlClient->performValidation();
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validations", $result)) {
$result["validations"] = array();
}
$result["validations"]["client.".$msg->getField()] = $msg->getMessage();
}
// serialize model to config and save
if ($valMsgs->count() == 0) {
$mdlClient->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
}
return $result;
}

public function searchClientAction()
{
$this->sessionClose();
$mdlClient = $this->getModel();
$grid = new UIModelGrid($mdlClient->clients->client);
return $grid->fetchBindRequest(
$this->request,
array("enabled", "name", "secret", "ip" )
);
}

public function getClientAction($uuid = null)
{
$mdlClient = $this->getModel();
if ($uuid != null) {
$node = $mdlClient->getNodeByReference('clients.client.' . $uuid);
if ($node != null) {
// return node
return array("client" => $node->getNodes());
}
} else {
$node = $mdlClient->clients->client->add();
return array("client" => $node->getNodes());
}
return array();
}

public function addClientAction()
{
$result = array("result" => "failed");
if ($this->request->isPost() && $this->request->hasPost("client")) {
$result = array("result" => "failed", "validations" => array());
$mdlClient = $this->getModel();
$node = $mdlClient->clients->client->Add();
$node->setNodes($this->request->getPost("client"));
$valMsgs = $mdlClient->performValidation();
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "client", $msg->getField());
$result["validations"][$fieldnm] = $msg->getMessage();
}
if (count($result['validations']) == 0) {
unset($result['validations']);
// save config if validated correctly
$mdlClient->serializeToConfig();
Config::getInstance()->save();
unset($result['validations']);
$result["result"] = "saved";
}
}
return $result;
}

public function delClientAction($uuid)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlClient = $this->getModel();
if ($uuid != null) {
if ($mdlClient->clients->client->del($uuid)) {
$mdlClient->serializeToConfig();
Config::getInstance()->save();
$result['result'] = 'deleted';
} else {
$result['result'] = 'not found';
}
}
}
return $result;
}

public function setClientAction($uuid)
{
if ($this->request->isPost() && $this->request->hasPost("client")) {
$mdlSetting = $this->getModel();
if ($uuid != null) {
$node = $mdlSetting->getNodeByReference('clients.client.' . $uuid);
if ($node != null) {
$result = array("result" => "failed", "validations" => array());
$clientInfo = $this->request->getPost("client");
$node->setNodes($clientInfo);
$valMsgs = $mdlSetting->performValidation();
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "client", $msg->getField());
$result["validations"][$fieldnm] = $msg->getMessage();
}
if (count($result['validations']) == 0) {
// save config if validated correctly
$mdlSetting->serializeToConfig();
Config::getInstance()->save();
$result = array("result" => "saved");
}
return $result;
}
}
}
return array("result" => "failed");
}

public function toggle_handler($uuid, $elements, $element)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlSetting = $this->getModel();
if ($uuid != null) {
$node = $mdlSetting->getNodeByReference($elements . '.'. $element .'.' . $uuid);
if ($node != null) {
if ($node->enabled->__toString() == "1") {
$result['result'] = "Disabled";
$node->enabled = "0";
} else {
$result['result'] = "Enabled";
$node->enabled = "1";
}
// if item has toggled, serialize to config and save
$mdlSetting->serializeToConfig();
Config::getInstance()->save();
}
}
}
return $result;
}

public function toggleClientAction($uuid)
{
return $this->toggle_handler($uuid, 'clients', 'client');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright (C) 2015 - 2017 Deciso B.V.
* Copyright (C) 2017 Michael Muenz
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

namespace OPNsense\Freeradius\Api;

use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Freeradius\General;
use \OPNsense\Core\Config;

class GeneralController extends ApiControllerBase
{
public function getAction()
{
// define list of configurable settings
$result = array();
if ($this->request->isGet()) {
$mdlGeneral = new General();
$result['general'] = $mdlGeneral->getNodes();
}
return $result;
}

public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlGeneral = new General();
$mdlGeneral->setNodes($this->request->getPost("general"));

// perform validation
$valMsgs = $mdlGeneral->performValidation();
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validations", $result)) {
$result["validations"] = array();
}
$result["validations"]["general.".$msg->getField()] = $msg->getMessage();
}

// serialize model to config and save
if ($valMsgs->count() == 0) {
$mdlGeneral->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
}
return $result;
}
}
Loading