Skip to content

Commit

Permalink
correct handling of the forwarded-for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
andponlin committed Jun 11, 2020
1 parent 206fdd3 commit 58bf369
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion haikudepotserver-docs/src/docbkx/part-deployment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Distributed under the terms of the MIT License.
</para>

<para>
<programlisting>docker run -v secrets:/secrets -it &lt;image-id&gt; /bin/bash</programlisting>
<programlisting>docker run -v secrets:/secrets -p 8080:8080 &lt;image-id&gt;</programlisting>
</para>

<para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import org.springframework.mail.MailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.web.context.support.ServletContextAttributeExporter;
import org.springframework.web.filter.ForwardedHeaderFilter;

import javax.servlet.Filter;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -148,4 +150,9 @@ public RepositoryAuthenticationFilter repositoryAuthenticationFilter(
);
}

@Bean
public Filter forwardedHeaderFilter() {
return new ForwardedHeaderFilter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.filter.ForwardedHeaderFilter;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.*;

import javax.servlet.Filter;
import java.util.stream.Stream;

@EnableWebMvc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import org.haiku.haikudepotserver.support.web.ErrorServlet;
import org.haiku.haikudepotserver.support.web.RemoteLogCaptureServlet;
import org.haiku.haikudepotserver.support.web.SessionListener;
import org.springframework.context.annotation.Bean;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.filter.ForwardedHeaderFilter;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
Expand Down Expand Up @@ -46,6 +49,7 @@ public void onStartup(ServletContext servletContext) {
registerJawrServlet(servletContext, "css");
registerJawrServlet(servletContext, "js");

registerSpringFilter(servletContext, "forwardedHeaderFilter", "/*");
registerSpringFilter(servletContext, "metricsFilter", "/*");
registerSpringFilter(servletContext, "authenticationFilter", "/*");
registerSpringFilter(servletContext, "repositoryAuthenticationFilter", "/" + RepositoryController.SEGMENT_REPOSITORY + "/*");
Expand Down

0 comments on commit 58bf369

Please sign in to comment.