Forcing SSL connection

481 views
Skip to first unread message

davin

unread,
Dec 24, 2010, 2:04:16 AM12/24/10
to play-framework
I was glad to see SSL support included in the latest 1.1 release. I
have SSL setup with jks keystore but I'm not sure how to force a
connection that comes in as http to switch to https. Any advice?

Thanks!

Guillaume Bort

unread,
Dec 24, 2010, 9:02:18 AM12/24/10
to play-fr...@googlegroups.com
In playapps.net, I use this:

public class ForceSSL extends Controller {

@Before
static void verifySSL() {
if(Play.mode == Play.Mode.PROD) {
if(!request.secure) {
redirect("https://" + request.host + request.url);
}
}
}

}

You wan mix it with any other controller using @With(ForceSSL.class)

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Reply all
Reply to author
Forward
0 new messages