Hoist RequireSslFilter out of WebModule

On googlesource.com we have a separate filter for this, and having two
of them causes problems.

Change-Id: If04b61be38eed67fa8edd5cbd164f4b97ea1e6e2
This commit is contained in:
Dave Borowitz
2015-11-10 14:31:11 -05:00
parent c131268d46
commit faf0802a35
4 changed files with 15 additions and 11 deletions

View File

@@ -34,11 +34,20 @@ import javax.servlet.http.HttpServletResponse;
/** Requires the connection to use SSL, redirects if not. */
@Singleton
class RequireSslFilter implements Filter {
static class Module extends ServletModule {
public class RequireSslFilter implements Filter {
public static class Module extends ServletModule {
private final boolean wantSsl;
@Inject
Module(@Nullable @CanonicalWebUrl String canonicalUrl) {
this.wantSsl = canonicalUrl != null && canonicalUrl.startsWith("https:");
}
@Override
protected void configureServlets() {
filter("/*").through(RequireSslFilter.class);
if (wantSsl) {
filter("/*").through(RequireSslFilter.class);
}
}
}