提起过滤器以迫使ssl [英] Lift filter to force ssl
本文介绍了提起过滤器以迫使ssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在struts应用程序中,我有一个过滤器,用于强制某些页面仅通过重定向通过https访问.我正在考虑将其移植为举升机,所以我的问题是:在这种环境下,是否存在举升"方式来实现这种过滤器,或者它与struts类似/相同?谢谢
in a struts application, I have a filter that forces certain pages to be accessed only over https via redirection. I'm thinking in porting it to lift so my question is: In the this environment, is there a "lift" way to implement such filter or is it similar/the same as in struts ? Thanks
推荐答案
在Lift中,SiteMap定义了页面访问规则.您可以创建一个SiteMap条目,该条目在某些页面上执行重定向到https站点的操作:
In Lift, the SiteMap defines the rules for page access. You can create a SiteMap entry that does a Redirect to the https site on certain pages:
// create an object that does a redirect to the https server if the
// request is on http
object RequireSSL extends Loc.EarlyResponse(
() => {
for {
r <- S.request
lowLevelReq <- Box !! r if lowLevelReq.scheme == "http"
} {
S.redirectTo("https://"+lowLevelReq.serverName+lowLevelReq.contextPath)
}
Empty
})
// Build SiteMap
def entries = (Menu("Home") / "index") ::
(Menu("Secure") / "secure" >> RequireSSL) ::
Nil
希望这会有所帮助.
这篇关于提起过滤器以迫使ssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文