Bypassing Spring Security

Today I set out to provide accessible endpoints to a web application already behind Spring Security. My configuration locks down all requests going to the server (as will be shown below), and there is no easy way of adding an excludes parameter to the DelegatingFilterProxy (see various questions on Stack Overflow).

My solution is actually pretty easy, just took a while to discern.

Spring Security Configuration

In my web.xml:
[code lang=”xml”]
<!– Enables Spring Security –>


The solution lies in my security-context.xml:
[code lang=”xml”]
<!– No security set for open URLs, must be declared before broader security –>
<security:http pattern="/unsecure/**" security="none"/>

<security:http auto-config="true">
<!– Restrict URLs based on role, in this
situation, all requests must be authenticated –>
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />

Adding the additional pattern pointing to “/unsecure/**” means any request going to has no security, but anything else going to will still require authentication.

Note: You must put this tag ahead of any broader patterns!