Sunday, July 15, 2012

Exclude resource files from Spring Security filtering

It's easy (if you know how) to exclude *.css, *.png and so force resource files from Spring Security filter application, even if your resources are scattered about all the project (different directories and different nesting levels).

Here is a Spring Security (version >= 3) config snippet which excludes from filtering all *.css files:
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
         xmlns:b="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http pattern="/**/*.css" security="none"/>
</b:beans>

No comments:

Post a Comment