My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SecuredRemoteAddressValve  
SecuredRemoteAddressValve is a Tomcat Valve to set "ServletRequest.isSecure() == true" for predefined remote addresses even if "ServletRequest.getScheme() == 'http'".
Phase-Implementation
Updated Nov 23, 2010 by cyrille....@gmail.com

Description

Some http requests are secured even if they don't use SSL. This is usually the case for http request emitted by applications that are located in the same data center / VLAN as the requested server. A typical scenario would be a web service consumed both by consumers located on the Internet and others located in the same data center. The first ones will use SSL when the second ones will not.

SecuredRemoteAddressValve is a Tomcat valve to set ServletRequest.isSecure() == true for predefined remote addresses even if ServletRequest.getScheme() == "http".

Thanks to this common java web security frameworks like Spring Security can still be used to enforce SSL for clients coming from non secured / non trusted networks like the Internet.

This valve is often preceded by the RemoteIpValve to get the remote address of the client even if the request goes through load balancers (e.g. F5 Big IP, Nortel Alteon) or proxies (e.g. Apache mod_proxy_http).

Valve Configuration

SecuredRemoteAddressValve attribute Description Format Default value
securedRemoteAddresses IP addresses for which ServletRequest.isSecure() must return true Comma delimited list of regular expressions (in the syntax supported by the java.util.regex.Pattern library) Class A, B and C private network IP address blocks : 10\.\d{1,3}\.\d{1,3}\.\d{1,3}, 192\.168\.\d{1,3}\.\d{1,3}, 172\\.(?:1[6-9]|2\\d|3[0-1]).\\d{1,3}.\\d{1,3}, 169\.254\.\d{1,3}\.\d{1,3}, 127\.\d{1,3}\.\d{1,3}\.\d{1,3}

Note : the default configuration can usually be used as internal servers are most of the time trusted.

Sample of default configuration : trust request coming from private network address blocks

SecuredRemoteAddressValve is preceded by RemoteIpValve to get the actual remote address of the calling client if a load balancer or a proxy is used between clients and the Tomcat server.

<Server ...>
   ...
   <Service name="Catalina">
      <Connector ... />

      <Engine ...>
         <!-- Process x-Forwarded-For to get remote address and X-Forwarded-Proto to identify SSL requests -->
         <Valve className="org.apache.catalina.connector.RemoteIpValve" protocolHeader="X-Forwarded-For" />

         <!-- Flag as secure all request coming from private network IP address blocks. Must be declared after RemoteIpValve -->
         <Valve className="org.apache.catalina.connector.SecuredRemoteAddressValve" />

         <!-- AccessLogValve must be declared after RemoteIpValve to get the remote address and the scheme https/http -->
         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="common" prefix="access_log."
            resolveHosts="false" suffix=".txt" />
         ...
         </Host>
      </Engine>
   </Service>
</Server>

Sample with secured remote addresses limited to 192.168.0.10 and 192.168.0.11

<Server ...>
   ...
   <Service name="Catalina">
      <Connector ... />

      <Engine ...>
         <!-- Process x-Forwarded-For to get remote address and X-Forwarded-Proto to identify SSL requests -->
         <Valve className="org.apache.catalina.connector.RemoteIpValve" protocolHeader="X-Forwarded-For" />

         <!-- Flag as secure all request coming from 192.168.0.10 and 192.168.0.11. Must be declared after RemoteIpValve -->
         <Valve className="org.apache.catalina.connector.SecuredRemoteAddressValve" 
                securedRemoteAddresses="192\.168\.0\.10,192\.168\.0\.10" />

         <!-- AccessLogValve must be declared after RemoteIpValve to get the remote address and the scheme https/http -->
         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="common" prefix="access_log."
            resolveHosts="false" suffix=".txt" />
         ...
         </Host>
      </Engine>
   </Service>
</Server>

Install / Download

Resources


Sign in to add a comment
Powered by Google Project Hosting