I have a Spring MVC application protected with Spring Security. Most applications use simple HTTP to save resources, but a small part processes more confidential information and requires an HTTPS channel.
Extract from security-config.xml :
<sec:http authentication-manager-ref="authenticationManager" ... > ... <sec:intercept-url pattern="/sec/**" requires-channel="https"/> <sec:intercept-url pattern="/**" requires-channel="http"/> </sec:http>
Everything worked fine until we decided to transfer it to the main server, where application servers work behind reverse proxies. And since HTTPS is now handled by reverse proxies, the application server only sees HTTP requests and denies access to the /sec/** hierarchy.
After some research, I found that proxies add the X-Forwarded-Proto: https header X-Forwarded-Proto: https (*) but in Spring Security HttpServletRequest.isSecure() used to determine the proposed channel security (fetching from the javadoc SecureChannelProcessor ).
How can I tell Spring Security that the X-Forwarded-Proto: https header is enough for a secure request?
I know that I could report about this part about the proxy configuration, but the proxy administrator really does not like this solution, because there are many applications behind the proxy, and the configuration can grow to an unmanaged state.
I am currently using Spring Security 3.2 with XML configuration, but I am ready to accept answers based on Java configuration and / or later.
(*) Of course, proxies remove the header if it was present in the incoming request, so the application can be sure of this.
Serge Ballesta
source share