[英]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中的標頭,那么我的問題就可以解決。
注意我已經研究了以下模塊:
簡而言之,我為什么要這樣做?:安全問題請參見OWASP。
在MOD_SECURITY框架中找到的答案
離開上面的問題后,我考慮了哪些apache模塊可以提供幫助。
然后,我在mod_security中搜索了此信息。
我發現Ryan Barnett的出色文章和規則集。
上方鏈接中的規則集:
# 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.