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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user