【问题标题】:Kohana sessions with HttpsKohana 与 Https 的会话
【发布时间】:2012-06-02 19:38:32
【问题描述】:

我有一个主控制器,它检查是否设置了会话安全,如果没有,它将重定向到安全控制器。

问题是安全控制器是通过 https,它检查密码并设置会话并重定向到主控制器。我无法通过 http 中的 https 访问会话集。

那我该如何使用 https 并重定向到普通的 http 呢?我需要 http 和 https 中的会话

有什么想法吗?

编辑

好的,我检查了一下,如果不保证安全,这是不可能的。 一种选择是让会话通过 GET 发送,但它显然不安全,那么如果在检查登录后我将它们重定向到一个 https 表单,该表单将会话发布到一个普通的 http 页面,在 html 页面上我检查标题并确保它来自我的 https 页面。 这听起来安全吗?

【问题讨论】:

    标签: session https kohana


    【解决方案1】:

    使您的整个应用程序都使用 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"
            )
        }
    }
    

    【讨论】:

      【解决方案2】:

      为什么不让您的整个页面成为安全网站 (https) 的一部分?如果不在站点之间传递 GET 密钥,我看不到一种方法来进行 http => https 转换。

      如果您的逻辑是从房子的 http 端的 cookie 中获取会话 id(只有密钥)并使其成为 https 端的 cookie(手动),我认为这不是一个巨大的安全问题在这所房子里面。然后,您可以执行正常的会话处理验证以查看它是否是有效会话。尽可能将您的逻辑与滥用隔离开来。

      在后端,您可以在站点之间共享会话信息,也可以根据检索到的会话 ID 触发从 http 到 https 的复制。取决于您的架构。

      【讨论】:

        猜你喜欢
        • 2017-10-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多