mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
www/web-proxy-sso: whitespace and style sweep
This commit is contained in:
+46
-46
@@ -33,69 +33,69 @@ use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\SSOProxyAD\SSOProxyAD;
|
||||
use \OPNsense\Core\Backend;
|
||||
use \OPNsense\Cron\Cron;
|
||||
|
||||
class ServiceController extends ApiControllerBase
|
||||
{
|
||||
|
||||
public function reloadAction()
|
||||
{
|
||||
$status = "failed";
|
||||
if ($this->request->isPost()) {
|
||||
$mdlSSOProxyAD = new SSOProxyAD();
|
||||
if ((string)$mdlSSOProxyAD->general->UpdateCron == "") {
|
||||
$mdlCron = new Cron();
|
||||
$mdlSSOProxyAD->general->UpdateCron = $mdlCron->newDailyJob("SSOProyAD", "ssoproxyad updateDomain", "SSOProxyAD updateDomain cron", "1");
|
||||
public function reloadAction()
|
||||
{
|
||||
$status = "failed";
|
||||
if ($this->request->isPost()) {
|
||||
$mdlSSOProxyAD = new SSOProxyAD();
|
||||
if ((string)$mdlSSOProxyAD->general->UpdateCron == "") {
|
||||
$mdlCron = new Cron();
|
||||
$mdlSSOProxyAD->general->UpdateCron = $mdlCron->newDailyJob("SSOProyAD", "ssoproxyad updateDomain", "SSOProxyAD updateDomain cron", "1");
|
||||
if ($mdlCron->performValidation()->count() == 0) {
|
||||
$mdlCron->serializeToConfig();
|
||||
$mdlMymodule->serializeToConfig($validateFullModel = false, $disable_validation = true);
|
||||
Config::getInstance()->save();
|
||||
}
|
||||
}
|
||||
$backend = new Backend();
|
||||
$bckresult = trim($backend->configdRun("template reload OPNsense.SSOProxyAD"));
|
||||
if ($bckresult == "OK") {
|
||||
$status = "ok";
|
||||
}
|
||||
}
|
||||
$backend = new Backend();
|
||||
$bckresult = trim($backend->configdRun("template reload OPNsense.SSOProxyAD"));
|
||||
if ($bckresult == "OK") {
|
||||
$status = "ok";
|
||||
}
|
||||
return array("status" => $status);
|
||||
}
|
||||
return array("status" => $status);
|
||||
}
|
||||
|
||||
public function testAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad test")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
public function testAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad test")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
}
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
|
||||
public function joinDomainAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad joinDomain")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
public function joinDomainAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad joinDomain")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
}
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
|
||||
public function updateDomainAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad updateDomain")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
public function updateDomainAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$bckresult = json_decode(trim($backend->configdRun("ssoproxyad updateDomain")), true);
|
||||
if ($bckresult !== null) {
|
||||
// only return valid json type responses
|
||||
return $bckresult;
|
||||
}
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
return array("message" => "unable to run config action");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-23
@@ -43,7 +43,7 @@ class SettingsController extends ApiControllerBase
|
||||
{
|
||||
// define list of configurable settings
|
||||
$result = array();
|
||||
if ($this->request->isGet()) {
|
||||
if ($this->request->isGet()) {
|
||||
$mdlSSOProxyAD= new SSOProxyAD();
|
||||
$result['ssoproxyad'] = $mdlSSOProxyAD->getNodes();
|
||||
}
|
||||
@@ -54,31 +54,30 @@ class SettingsController extends ApiControllerBase
|
||||
* 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"));
|
||||
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();
|
||||
// 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();
|
||||
}
|
||||
$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";
|
||||
// serialize model to config and save
|
||||
if ($valMsgs->count() == 0) {
|
||||
$mdlSSOProxyAD->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "saved";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
namespace OPNsense\SSOProxyAD;
|
||||
|
||||
class IndexController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
@@ -37,6 +38,6 @@ class IndexController extends \OPNsense\Base\IndexController
|
||||
// pick the template to serve to our users.
|
||||
$this->view->pick('OPNsense/SSOProxyAD/index');
|
||||
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ class SSOProxyAD implements IAuthConnector
|
||||
* unused
|
||||
* @return array mixed named list of authentication properties
|
||||
*/
|
||||
public function getLastAuthProperties()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
public function getLastAuthProperties()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function authenticate($username,$password)
|
||||
{
|
||||
}
|
||||
public function authenticate($username, $password)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<model>
|
||||
<mount>//OPNsense/ssoproxyad</mount>
|
||||
<description>
|
||||
SSO Active Directory plugin
|
||||
SSO Active Directory plugin
|
||||
</description>
|
||||
<items>
|
||||
<general>
|
||||
|
||||
@@ -34,6 +34,7 @@ require_once("config.inc");
|
||||
require_once("certs.inc");
|
||||
require_once("legacy_bindings.inc");
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
global $config;
|
||||
|
||||
$configObj = Config::getInstance()->object();
|
||||
@@ -41,12 +42,12 @@ $hostname = $configObj->system->hostname;
|
||||
$fqdn = $hostname . "." . $configObj->system->domain;
|
||||
if (isset($configObj->OPNsense->ssoproxyad)) {
|
||||
foreach ($configObj->OPNsense->ssoproxyad->general as $ssoproxyad) {
|
||||
$enabled = $ssoproxyad->Enabled;
|
||||
$domainname = $ssoproxyad->DomainName;
|
||||
$domaindc = $ssoproxyad->DomainDC;
|
||||
$domainversion = $ssoproxyad->DomainVersion;
|
||||
$domainuser = $ssoproxyad->DomainUser;
|
||||
$domainpassword = $ssoproxyad->DomainPassword;
|
||||
$enabled = $ssoproxyad->Enabled;
|
||||
$domainname = $ssoproxyad->DomainName;
|
||||
$domaindc = $ssoproxyad->DomainDC;
|
||||
$domainversion = $ssoproxyad->DomainVersion;
|
||||
$domainuser = $ssoproxyad->DomainUser;
|
||||
$domainpassword = $ssoproxyad->DomainPassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,35 +56,32 @@ $cmd_2003 = '/usr/local/sbin/msktutil -c -b CN=COMPUTERS -s HTTP -k ' . $keytab
|
||||
$cmd_2008 = '/usr/local/sbin/msktutil -c -b CN=COMPUTERS -s HTTP -k ' . $keytab . ' --computer-name ' . strtoupper($hostname) . ' --upn HTTP/' . $fqdn. ' --server ' . $domaindc . ' --enctypes 28 2>&1';
|
||||
|
||||
if ($enabled == 1) {
|
||||
$krb5secret = '/usr/local/etc/ssoproxyad/krb5secret';
|
||||
if ( !file_exists($keytab) ) {
|
||||
file_put_contents($krb5secret, $domainpassword);
|
||||
chmod($krb5secret, 0600);
|
||||
exec('/usr/bin/kinit --password-file="' . $krb5secret . '" ' . $domainuser. "@" . strtoupper($domainname) . " 2>&1",$output_kinit,$error_kinit);
|
||||
if ($error_kinit > 0) {
|
||||
$return = array('message' => "$output_kinit");
|
||||
}
|
||||
else {
|
||||
if ( $domainversion == '2003' ) {
|
||||
exec($cmd_2003,$output_msktutil,$error_msktutil);
|
||||
} elseif ( $domainversion == '2008' ) {
|
||||
exec($cmd_2008,$output_msktutil,$error_msktutil);
|
||||
}
|
||||
if ( (file_exists($keytab)) and ($error_msktutil <= 0) ) {
|
||||
chown($keytab,'squid');
|
||||
chgrp($keytab,'squid');
|
||||
exec("/usr/bin/kdestroy 2>&1",$output_kdestroy,$error_kdestroy);
|
||||
unlink($krb5secret);
|
||||
$return = array('message' => "keytab created");
|
||||
}
|
||||
else {
|
||||
$out = implode($output_msktutil);
|
||||
$return = array('message' => "Unable to create keytab: $out");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return = array('message' => "keytab already exists");
|
||||
}
|
||||
$krb5secret = '/usr/local/etc/ssoproxyad/krb5secret';
|
||||
if (!file_exists($keytab)) {
|
||||
file_put_contents($krb5secret, $domainpassword);
|
||||
chmod($krb5secret, 0600);
|
||||
exec('/usr/bin/kinit --password-file="' . $krb5secret . '" ' . $domainuser. "@" . strtoupper($domainname) . " 2>&1", $output_kinit, $error_kinit);
|
||||
if ($error_kinit > 0) {
|
||||
$return = array('message' => "$output_kinit");
|
||||
} else {
|
||||
if ($domainversion == '2003') {
|
||||
exec($cmd_2003, $output_msktutil, $error_msktutil);
|
||||
} elseif ($domainversion == '2008') {
|
||||
exec($cmd_2008, $output_msktutil, $error_msktutil);
|
||||
}
|
||||
if ((file_exists($keytab)) and ($error_msktutil <= 0)) {
|
||||
chown($keytab, 'squid');
|
||||
chgrp($keytab, 'squid');
|
||||
exec("/usr/bin/kdestroy 2>&1", $output_kdestroy, $error_kdestroy);
|
||||
unlink($krb5secret);
|
||||
$return = array('message' => "keytab created");
|
||||
} else {
|
||||
$out = implode($output_msktutil);
|
||||
$return = array('message' => "Unable to create keytab: $out");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$return = array('message' => "keytab already exists");
|
||||
}
|
||||
}
|
||||
echo json_encode($return);
|
||||
|
||||
@@ -34,6 +34,7 @@ require_once("config.inc");
|
||||
require_once("certs.inc");
|
||||
require_once("legacy_bindings.inc");
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
global $config;
|
||||
|
||||
$configObj = Config::getInstance()->object();
|
||||
@@ -41,26 +42,24 @@ $hostname = $configObj->system->hostname;
|
||||
$fqdn = $hostname . "." . $configObj->system->domain;
|
||||
if (isset($configObj->OPNsense->ssoproxyad)) {
|
||||
foreach ($configObj->OPNsense->ssoproxyad->general as $ssoproxyad) {
|
||||
$enabled = $ssoproxyad->Enabled;
|
||||
$enabled = $ssoproxyad->Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
if ($enabled == 1) {
|
||||
$keytab = '/usr/local/etc/ssoproxyad/PROXY.keytab';
|
||||
if ( file_exists($keytab) ) {
|
||||
$cmd = '/usr/local/sbin/msktutil --auto-update --computer-name ' . strtolower($hostname) . ' --keytab ' . $keytab . ' 2>&1';
|
||||
exec($cmd,$output_msktutil,$error_msktutil);
|
||||
$out = implode($output_msktutil);
|
||||
if ($error_msktutil > 0) {
|
||||
$return = array('message' => "Unable to auto-update: $out)");
|
||||
}
|
||||
else {
|
||||
$return = array('message' => "Auto-update successful: $out");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return = array('message' => "keytab do not exists");
|
||||
}
|
||||
$keytab = '/usr/local/etc/ssoproxyad/PROXY.keytab';
|
||||
if (file_exists($keytab)) {
|
||||
$cmd = '/usr/local/sbin/msktutil --auto-update --computer-name ' . strtolower($hostname) . ' --keytab ' . $keytab . ' 2>&1';
|
||||
exec($cmd, $output_msktutil, $error_msktutil);
|
||||
$out = implode($output_msktutil);
|
||||
if ($error_msktutil > 0) {
|
||||
$return = array('message' => "Unable to auto-update: $out)");
|
||||
} else {
|
||||
$return = array('message' => "Auto-update successful: $out");
|
||||
}
|
||||
} else {
|
||||
$return = array('message' => "keytab do not exists");
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
Reference in New Issue
Block a user