This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new controller plugin to validate in each controller action if all required commands to run the module properly are given in the used Console/Profile Command ACL. Additionally a new view helper is introduced to centralize the ACL alert message which is displayed when the given Command ACL does not fit the requirements. This commit changes the views and controllers of the following modules: - Dashboard - Jobs - Restore - Clients - Schedules - Storages - Pools - Media/Volumes - Director Furthermore this commit removes some whitespace from the Director Model.
- Loading branch information
1 parent
cbcc032
commit 00439f5
Showing
36 changed files
with
533 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
module/Application/src/Application/Controller/Plugin/CommandACLPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Application\Controller\Plugin; | ||
|
||
use Zend\Mvc\Controller\Plugin\AbstractPlugin; | ||
|
||
class CommandACLPlugin extends AbstractPlugin | ||
{ | ||
private $commands = null; | ||
private $required = null; | ||
|
||
public function validate($commands=null, $required=null) | ||
{ | ||
$this->commands = $commands; | ||
$this->required = $required; | ||
|
||
foreach($this->required as $cmd) { | ||
if($this->commands[$cmd]['permission'] == 0) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
module/Application/src/Application/View/Helper/ACLAlert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* bareos-webui - Bareos Web-Frontend | ||
* | ||
* @link https://github.com/bareos/bareos-webui for the canonical source repository | ||
* @copyright Copyright (c) 2013-2016 Bareos GmbH & Co. KG (http://www.bareos.org/) | ||
* @license GNU Affero General Public License (http://www.gnu.org/licenses/) | ||
* @author Frank Bergkemper | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace Application\View\Helper; | ||
|
||
use Zend\View\Helper\AbstractHelper; | ||
|
||
class ACLAlert extends AbstractHelper | ||
{ | ||
private $required_commands = null; | ||
private $alert = null; | ||
|
||
public function __invoke($required_commands) | ||
{ | ||
$msg_part_a = _('Sorry, it seems you are not authorized to run this module. If you think this is an error, please contact your local administrator.'); | ||
$msg_part_b = _('Please read the <a href="http://doc.bareos.org/master/html/bareos-manual-main-reference.html#sec:webui-console" target="_blank">Bareos documentation</a> for any additional information on how to configure the Command ACL directive of your Console/Profile resources. Following is a list of required commands which need to be in your Command ACL to run this module properly:'); | ||
|
||
$this->required_commands = $required_commands; | ||
|
||
$this->alert = '<div class="container-fluid">'; | ||
$this->alert .= '<div class="row">'; | ||
$this->alert .= '<div class="col-md-6">'; | ||
$this->alert .= '<div class="alert alert-danger"><b>'.$msg_part_a.'</b></div>'; | ||
$this->alert .= $msg_part_b; | ||
|
||
$this->alert .= '</br></br>'; | ||
$this->alert .= '<ul>'; | ||
|
||
foreach($this->required_commands as $cmd) { | ||
$this->alert .= '<li>'.$cmd.'</li>'; | ||
} | ||
|
||
$this->alert .= '</ul>'; | ||
$this->alert .= '</div>'; | ||
$this->alert .= '<div class="col-md-6"></div>'; | ||
$this->alert .= '</div>'; | ||
$this->alert .= '</div>'; | ||
|
||
return $this->alert; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.