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
To force SSL connections to a site edit the .htaccess file in the folder containing the site. You can do this through cPanel File Manager or via FTP (download the file, edit it and upload again). After saving the file, try visiting your website using an http:// URL - you'll find that it gets redirected to the https:// version
The .htaccess file can also be used to force HTTPS on specific folders. However, the file should be placed in the folder that will have the HTTPS connection. Make sure to change the folder references to the actual directory names. After making the changes, clear your browser’s cache and try to connect to your site via HTTP.
Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folder with your actual domain name and folder you want to force the SSL on. To force your visitors to use your Shared SSL certificate:
Servlet container does not have any information about the Spring’s application context, but spring security needs security filters to execute the task.. Since DelegatingFilterProxy is a servlet filter, the application server register it as a normal filter in the context.
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
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With