【问题标题】:HttpOnly and Secure not set for sub path cookie未为子路径 cookie 设置 HttpOnly 和 Secure
【发布时间】:2013-01-15 14:21:13
【问题描述】:

我在 web.config 中有以下内容...

<httpCookies httpOnlyCookies="true" requireSSL="true" />

这些设置已正确应用于我网站的 cookie,但名为“UMB_PANEL”且路径为“/umbraco”的 cookie 除外。

我尝试将具有重复设置的 web.config 文件添加到“/umbraco”文件夹中,但没有效果。

如何让这些 cookie 设置应用于整个网站?

【问题讨论】:

    标签: asp.net umbraco httponly


    【解决方案1】:

    参加聚会有点晚了,但您可以通过Outbound Rules 实现您所需要的。

    这将重写任何没有Secure=true 的 cookie 以确保安全:

    <outboundRules>
        <rule name="Add Secure Cookies" preCondition="No Secure">
          <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false"/>
          <action type="Rewrite" value="{R:0}; Secure=true"/>
          <conditions/>
        </rule>
        <preConditions>
          <preCondition name="No Secure">
            <add input="{RESPONSE_Set_Cookie}" pattern="."/>
            <add input="{RESPONSE_Set_Cookie}" pattern="; Secure=true" negate="true"/>
          </preCondition>
        </preConditions>
      </outboundRules>
    

    如果您需要 pattern 以匹配特定的 cookie,您可以调整它,例如:^(UMB_PANEL).*

    【讨论】:

      【解决方案2】:

      我相信只有在您登录 Umbraco 管理区域时才会设置 cookie。

      http://our.umbraco.org/forum/using/ui-questions/20674-Does-Umbraco-make-use-of-Cookies-anywhere-in-the-core-product

      我的猜测是您的主要网站用户永远不会获得该 cookie。我意识到这不是直接回答问题,但也许它使它成为一个有争议的问题?

      【讨论】:

      • 恐怕不行,客户仍然认为这是个问题。
      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 2021-08-01
      • 2017-11-17
      • 2020-01-06
      • 2023-04-04
      • 2013-04-10
      • 1970-01-01
      • 2012-03-03
      相关资源
      最近更新 更多