2009-04-15 59 views

回答

6

因此,這是一個解決方案,我已經臨到。我下面的代碼片段添加到beforeFilter()AppController

if (!in_array($this->action, $this->Security->requireSecure) and env('HTTPS')) 
    $this->_unforceSSL(); 

的函數定義爲:

function _unforceSSL() { 
    $this->redirect('http://' . $_SERVER['SERVER_NAME'] . $this->here); 
} 
3

確保使用需要的安全網頁的安全連接一個cookie,和正常的cookie爲非安全頁面。這樣,如果有人捕獲到非安全Cookie,他們將無法劫持任何敏感信息。

2

什麼,我不重定向方法一樣的是,用戶還是到不安全的網址,只有在此之後,他被重定向。

我想回到什麼地方,在根據你傳遞一個SSL /非SSL鏈接的HTML的「鏈接/ URL級別上進行,用類似的東西: http://cakephp.1045679.n5.nabble.com/Re-Login-through-HTTPS-on-CakePHP-td1257438.html 而且使用安全組件

稍後編輯,我做了一件比較容易,只是做了我的工作做好,我嘗試創建一個簡單的例子(不要忘了在配置/ core.php文件或bootstrap.php中定義MYAPP_SECURE_URL): 在應用我創建app_helper。 PHP:

class AppHelper extends Helper { 
    function url($url = null, $full = false) { 
     if($url['action'] == 'login' && $url['controller'] == 'users') { 
      return MYAPP_SECURE_URL.'/users/login'; 
     } 
     return h(Router::url($url, $full)); 
    } 
}