Skip to content

Commit

Permalink
www/web-proxy-sso: adapt to mutable thingy, fix update-only and typo
Browse files Browse the repository at this point in the history
PR: #43
  • Loading branch information
fichtner committed Oct 22, 2016
1 parent fe6f117 commit 1a14d86
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 77 deletions.
@@ -1,7 +1,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -24,7 +24,6 @@
* 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\SSOProxyAD\Api;
Expand Down
@@ -1,7 +1,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -24,59 +24,28 @@
* 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\SSOProxyAD\Api;

use \OPNsense\Base\ApiControllerBase;
use \OPNsense\SSOProxyAD\SSOProxyAD;
use \OPNsense\Base\ApiMutableModelControllerBase;
use \OPNsense\Core\Config;

class SettingsController extends ApiControllerBase
class SettingsController extends ApiMutableModelControllerBase
{
/*
* retrieve SSO Proxy Active Directory general settings
* @return array general settings
static protected $internalModelClass = '\OPNsense\SSOProxyAD\SSOProxyAD';
static protected $internalModelName = 'ssoproxyad';

/**
* @return array plain model settings (non repeating items)
*/
public function getAction()
protected function getModelNodes()
{
// define list of configurable settings
$settingsNodes = array('general');
$result = array();
if ($this->request->isGet()) {
$mdlSSOProxyAD= new SSOProxyAD();
$result['ssoproxyad'] = $mdlSSOProxyAD->getNodes();
}
return $result;
}

/**
* update SSOProxyAD settings
* @return array status
*/
public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlSSOProxyAD= new SSOProxyAD();
$mdlSSOProxyAD->setNodes($this->request->getPost("ssoproxyad"));

// perform validation
$valMsgs = $mdlSSOProxyAD->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) {
$mdlSSOProxyAD->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
$mdlSSO = $this->getModel();
foreach ($settingsNodes as $key) {
$result[$key] = $mdlSSO->$key->getNodes();
}
return $result;
}
Expand Down
@@ -1,7 +1,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -24,7 +24,6 @@
* 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\SSOProxyAD;
Expand All @@ -33,11 +32,8 @@ class IndexController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
// set page title, used by the standard template in layouts/default.volt.
$this->view->title = "SSO Proxy Active Directory";
// pick the template to serve to our users.
$this->view->title = gettext('SSO Proxy Active Directory');
$this->view->pick('OPNsense/SSOProxyAD/index');

$this->view->generalForm = $this->getForm("general");
}
}
Expand Up @@ -22,7 +22,7 @@
</field>
<field>
<id>ssoproxyad.general.DomainUser</id>
<label>Active Directory Domin User</label>
<label>Active Directory Domain User</label>
<type>text</type>
</field>
<field>
Expand Down
@@ -1,7 +1,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -24,7 +24,6 @@
* 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\Auth;
Expand Down
@@ -1,7 +1,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -24,8 +24,8 @@
* 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\SSOProxyAD;

use OPNsense\Base\BaseModel;
Expand Down
Expand Up @@ -21,7 +21,7 @@
<DomainUser type="TextField">
<Required>Y</Required>
</DomainUser>
<DomainPassword type="UpdateOnly">
<DomainPassword type="UpdateOnlyTextField">
<Required>Y</Required>
</DomainPassword>
<UpdateCron type="ModelRelationField">
Expand Down
@@ -1,6 +1,5 @@
{#
Copyright (C) 2016 gitdevmod@github.com

Copyright (C) 2016 <gitdevmod@github.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -23,7 +22,6 @@ 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.

#}

{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_GeneralSettings'])}}
Expand Down
Expand Up @@ -2,8 +2,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -26,13 +25,13 @@
* 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.
*
*/

// Use legacy code to export certificates to the filesystem.
require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");

use OPNsense\Core\Config;

global $config;
Expand Down
@@ -1,7 +1,7 @@
#!/usr/local/bin/python2.7

"""
Copyright (c) 2015 Ad Schellevis
Copyright (c) 2016 <gitdevmod@github.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand All @@ -24,11 +24,8 @@
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.
--------------------------------------------------------------------------------------
perform some tests for the helloworld application
"""

import os
import socket
import json
Expand Down
Expand Up @@ -2,8 +2,7 @@
<?php

/**
* Copyright (C) 2016 gitdevmod@github.com
*
* Copyright (C) 2016 <gitdevmod@github.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -26,13 +25,13 @@
* 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.
*
*/

// Use legacy code to export certificates to the filesystem.
require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");

use OPNsense\Core\Config;

global $config;
Expand Down

0 comments on commit 1a14d86

Please sign in to comment.