2012-06-02 58 views
0

我有一個主控制器,檢查會話安全設置,如果沒有它將重定向到安全控制器。Kohana會話與Https

問題是安全控制器是通過https,它檢查密碼並設置會話並重定向到主控制器。我無法通過http訪問通過http設置的會話。

如何使用https並重定向到正常的http呢?我需要http和https中的會話Anyideas?

編輯

OK,我檢查四周,它是不是真的可以不保持事物的安全。 其中一個選擇是讓會話通過GET發送,但顯然不安全,那麼如果在檢查登錄後我將它們重定向到https表單,並將該會話發佈到正常的http頁面,那麼在html頁面上我會檢查標題並確保它來自我的https頁面。 這聽起來很安全嗎?

回答

0

使您的整個應用程序HTTPS。附件是我用幾乎我所有的網站塊,重定向80一切443

## 
# Sample config for a site needing SSL 
# 

$HTTP["host"] =~ "^ssl_example.localhost(:[0-9]+)?$" { 
    # Serve everything over HTTPS 
    $SERVER["socket"] == ":80" { 
     url.redirect-code = 301 
     url.redirect = ("/(.*)" => "https://ssl_example.localhost:%1/$1") 
    } 

    # This would be a great place to test SSL config for QA/Dev zones... 
    $SERVER["socket"] == ":443" { 
     ssl.engine = "enable" 
     ssl.pemfile = rootdir + "/etc/ssl/example.pem" 
     server.document-root = "/home/crosslight/ssl_example/default" 
     accesslog.filename = rootdir + "/var/log/ssl_example.log" 
     server.errorlog = rootdir + "/var/log/ssl_example.error.log" 
     server.tag = "Crosslight (lighttpd-1.4.28 + php-5.3.3)/SSL" 

     // CodeIgniter/Kohana rewrite rules 
     url.rewrite-once = (
      "^/index\.php" => "/index.php", #truncate index.php?params to just index.php 
      #### Serve static content 
      "^/(static.*)" => "/$1", 
      "^/(blog.*)" => "/$1", 
      "^/(.*)$" => "/index.php/$1" 
     ) 
    } 
} 
0

爲什麼不把安全網站的整個網頁的一部分(HTTPS)?我看不到在網站之間傳遞GET密鑰的情況下執行http => https轉換的方法。

我不認爲這是一個巨大的安全問題,如果你的邏輯是從房子的http端獲取cookie的會話id(只有密鑰),並將其設置爲cookie(手動)在https房子的一側。然後,您可以執行常規會話處理驗證,以查看它是否是有效的會話。儘可能避免濫用您的邏輯。

在後端,您可以共享站點之間的會話信息,或者您可以基於檢索到的會話標識從http到https觸發副本。取決於你的架構。