Optimised Service Display, extended SSL module functionality

This commit is contained in:
Deon George
2016-07-27 14:25:17 +10:00
parent 3d3c38b0a0
commit 5ab2d6205f
30 changed files with 455 additions and 258 deletions

View File

@@ -10,6 +10,8 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Service_Ssl extends Controller_Service {
protected $auth_required = TRUE;
protected $secure_actions = array(
'list'=>TRUE,
);

View File

@@ -10,6 +10,8 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_SSL extends Controller_SSL {
protected $auth_required = TRUE;
protected $secure_actions = array(
'add'=>TRUE,
'edit'=>TRUE,

View File

@@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides SSL management
*
* @package SSL
* @category Controllers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_SSL extends Controller_TemplateDefault {
}
?>

View File

@@ -0,0 +1,64 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides SSL management
*
* @package SSL
* @category Controllers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_SSL extends Controller_TemplateDefault {
protected $auth_required = false;
/**
* Render out an SSL CA certificate
*/
public function action_ca() {
$o = ORM::factory('SSL_CA',$this->request->param('id'));
$this->response->body($o->loaded() ? $o->sign_cert."\n" : NULL);
$this->response->headers(array('Content-Type' => 'text/plain'));
if ($o->loaded() AND ! is_null($this->request->query('download')))
$this->response->headers('Content-Disposition','attachment; filename="'.$o->id.'.ca.crt"');
$this->auto_render = FALSE;
}
/**
* Render the public certificate of a service
*/
public function action_cert() {
$o = ORM::factory('Service',$this->request->param('id'));
if ($o->loaded() and ($o->plugin() instanceof Model_Service_Plugin))
$this->response->body($o->plugin()->cert."\n");
$this->response->headers(array('Content-Type' => 'text/plain'));
if ($o->loaded() AND ! is_null($this->request->query('download')))
$this->response->headers('Content-Disposition','attachment; filename="'.$o->id.'.crt"');
$this->auto_render = FALSE;
}
/**
* Render out an SSL CA chain
*/
public function action_chain() {
$result = '';
$o = ORM::factory('Service',$this->request->param('id'));
if ($o->loaded() and $o->plugin() instanceof Model_Service_Plugin_Ssl) {
foreach ($o->plugin()->chain() as $cao)
$result .= $cao->sign_cert."\n";
}
$this->response->body($result);
$this->response->headers(array('Content-Type' => 'text/plain'));
if ($o->loaded() AND ! is_null($this->request->query('download')))
$this->response->headers('Content-Disposition','attachment; filename="ca.crts"');
$this->auto_render = FALSE;
}
}
?>

View File

@@ -9,9 +9,12 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_User_SSL extends Controller_SSL {
class Controller_User_Ssl extends Controller_Ssl {
protected $auth_required = TRUE;
protected $secure_actions = array(
'download'=>FALSE,
'download'=>TRUE,
'key'=>TRUE,
);
public function action_download() {
@@ -22,7 +25,7 @@ class Controller_User_SSL extends Controller_SSL {
$passwd = $this->request->post('passwd');
if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
if (! Auth::instance()->get_user()->isAdmin() AND strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
SystemMessage::add(array(
'title'=>_('Validation failed'),
'type'=>'error',
@@ -50,5 +53,23 @@ class Controller_User_SSL extends Controller_SSL {
$this->response->headers('Content-Disposition','attachment; filename="'.basename($file).'"');
$this->response->body($x);
}
/**
* Render the private key of a service
*/
public function action_key() {
$so = ORM::factory('Service',$this->request->param('id'));
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
if ($so->plugin() instanceof Model_Service_Plugin)
$this->response->body($so->plugin()->pk."\n");
$this->response->headers(array('Content-Type' => 'text/plain'));
if ($so->loaded() AND ! is_null($this->request->query('download')))
$this->response->headers('Content-Disposition','attachment; filename="'.$so->id.'.key"');
$this->auto_render = FALSE;
}
}
?>