【发布时间】:2012-11-29 13:44:58
【问题描述】:
我有一个 cakephp 2 应用程序。我向其中添加了 ssl,站点中有一个表单,其字段使用 JavaScript 填充,表单是使用 JavaScript 提交的。启用安全组件后,我无法提交网站。我知道原因是在这个表单中我没有在某些部分使用表单助手。我确信有办法绕过特定方法的安全组件。我尝试了很多,但它不起作用。
以下是代码。
app/controller/appcontroller.php
class AppController extends Controller {
public $components = array('Session',
'Auth'=> array(
'authenticate' => `array('Form' =>array('fields'=>array('username' => 'email'))))`,
'Acl' ,
'Email' => array('from' => 'donotreply@qpaper.in', 'sendAs' => 'html',
)
,'Security'=> array( 'allowedControllers'=>array('tests','live_tests'),'allowedActions'=>array('taketest','create_test'))
);
public $helpers = array('Html', 'Form','Session','Js');
function beforeFilter() {
Security::setHash('md5');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginError = 'Invalid Username or Password.';
$this->Auth->authError = "You are not authorized to access.";
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->authorize = 'Actions';
$this->Auth->actionPath = 'Controllers/';
$this->Security->blackHoleCallback = 'forceSSL';
$this->Security->requireSecure();
}
public function forceSSL() {
$this->redirect('https://' . env('SERVER_NAME') . $this->here);
}
}
我在 appcontroller 中强制使用 https
我要使用的表单在一个名为 testcontroller 的控制器和一个名为 test 的方法中
感谢您的宝贵时间!
【问题讨论】:
-
你可以通过重写让网络服务器做到这一点。您正在运行什么类型的网络服务。
-
是的,我也是这么想的.. 因为这个应用程序是构建的,所以对于其他几个表单也有同样的问题..@ColbyGuyer 我正在使用 APACHE
-
我也会在配置和代码中做 https。
标签: cakephp