Updates to SSL and other general items
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_SSL extends Controller_SSL {
|
||||
class Controller_Admin_Ssl extends Controller_Ssl {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
protected $secure_actions = array(
|
||||
|
@@ -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-2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_SSL extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
27
modules/ssl/classes/Controller/Ssl.php
Normal file
27
modules/ssl/classes/Controller/Ssl.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides SSL management
|
||||
*
|
||||
* @package SSL
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Ssl extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_download() {
|
||||
$so = ORM::factory('SSL_CA')->where('id','=',$this->request->param('id'))->or_where('name','=',$this->request->param('id'))->find();
|
||||
|
||||
if (! $so->loaded() OR ! $so->cert)
|
||||
throw HTTP_Exception::factory(404,'SSL either doesnt exist');
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','plain/text');
|
||||
$this->response->headers('Content-Disposition','attachment; filename="'.$so->name.'.crt"');
|
||||
$this->response->body($so->cert);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
* @license http://dev.leenooks.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(
|
||||
@@ -19,31 +19,58 @@ class Controller_User_SSL extends Controller_SSL {
|
||||
);
|
||||
|
||||
public function action_add() {
|
||||
if ($this->request->post()) {
|
||||
$so = ORM::factory('SSL');
|
||||
if ($this->request->post() OR $_FILES) {
|
||||
if ($_FILES AND $this->request->post('csr'))
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Validation failed'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Only supply a CSR file OR the CSR text, not both!'),
|
||||
));
|
||||
|
||||
$so->account_id = (string)Auth::instance()->get_user();
|
||||
else {
|
||||
|
||||
// Set our values, so that our filters have data
|
||||
$so->values($this->request->post());
|
||||
|
||||
$this->save($so);
|
||||
$so = ORM::factory('SSL');
|
||||
$so->account_id = (string)Auth::instance()->get_user();
|
||||
|
||||
if ($so->saved())
|
||||
HTTP::redirect(URL::link('user','ssl/view/'.$so->id));
|
||||
// Set our values, so that our filters have data
|
||||
$so->values($this->request->post());
|
||||
|
||||
if ($_FILES) {
|
||||
// Process upload
|
||||
$files = Validation::factory($_FILES)
|
||||
->rule('csr_file','Upload::valid')
|
||||
->rule('csr_file','Upload::not_empty')
|
||||
->rule('csr_file','Upload::type',array(':value',array('csr')))
|
||||
->rule('csr_file','Upload::size',array(':value','512K'));
|
||||
|
||||
if ($files->check())
|
||||
foreach ($files->data() as $file) {
|
||||
$so->csr = file_get_contents($file['tmp_name']);
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $so->csr)
|
||||
throw HTTP_Exception::factory(501,'No CSR data :csr_file?',$files->errors('user/ssl/add'));
|
||||
}
|
||||
|
||||
$this->save($so);
|
||||
|
||||
if ($so->saved())
|
||||
HTTP::redirect(URL::link('user','ssl/view/'.$so->id));
|
||||
}
|
||||
}
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add/Edit Record')
|
||||
->title_icon('fa-wrench')
|
||||
->title('SSL Certificate')
|
||||
->title_icon('fa-certificate')
|
||||
->body(View::factory('ssl/user/add')->set('o',$this->ao));
|
||||
}
|
||||
|
||||
public function action_download() {
|
||||
$passwd_len = Kohana::$config->load('ssl')->minpass_length;
|
||||
|
||||
$so = ORM::factory('SSL',$this->request->post('sid'));
|
||||
$so = ORM::factory('SSL',$this->request->param('id'));
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
|
||||
throw HTTP_Exception::factory(403,'SSL either doesnt exist, or you are not authorised to see it');
|
||||
|
Reference in New Issue
Block a user