簡體   English   中英

在Java中生成內容后,在Apache中轉換set-cookie Session Cookie標頭

[英]Transforming a set-cookie Session Cookie header in Apache after the content is generated in Java

我如何擁有一個apache配置,該配置接受由Java應用程序服務器生成的原始網頁,並將set-cookie會話標頭轉換為具有額外的標志。

Set-Cookie:JSESSIONID=f232xxx; path=/moedev-wss; secure

Set-Cookie:JSESSIONID=f232xxx; path=/moedev-wss; secure; httponly

不幸的是,我擁有的Java代碼無法輕松更新,但是如果我可以更改Apache中的標頭,那么我的問題就可以解決。

注意我已經研究了以下模塊:

  • mod_headers:無法搜索其他生成器生成的內容。
  • mod_rewrite:不編輯未代理的內容。
  • mod_proxy:不編輯未代理的內容。

簡而言之,我為什么要這樣做?:安全問題請參見OWASP。

在MOD_SECURITY框架中找到的答案

離開上面的問題后,我考慮了哪些apache模塊可以提供幫助。

然后,我在mod_security中搜索了此信息。

我發現Ryan Barnett的出色文章和規則集。

使用HTTPOnly標志幫助保護Cookies

上方鏈接中的規則集:

# Identifies SessiondIDs without HTTPOnly flag and sets the "http_cookie" ENV
# Token for Apache to read
SecRule RESPONSE_HEADERS:/Set-Cookie2?/ "!(?i:\;? ?httponly;?)" "chain,phase:3,t:none,pass,nolog"
  SecRule MATCHED_VAR "(?i:(j?sessionid|(php)?sessid|(asp|jserv|jw)?session[-_]?(id)?|cf(id|token)|sid))" "t:none,setenv:http_cookie=%{matched_var}"

# Now we use the Apache Header directive to set the new data

Header set Set-Cookie "%{http_cookie}e; HTTPOnly" env=http_cookie

我要感謝Ryan Barnett和一般的mod_security。

現在,我將繼續在我的環境中測試該解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM