Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security: how to exclude certain resources?

I have the following definition...

    <bean id="fsi" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">     <property name="authenticationManager" ref="authenticationManager"/>     <property name="accessDecisionManager" ref="httpRequestAccessDecisionManager"/>     <property name="objectDefinitionSource">       <sec:filter-invocation-definition-source >             <sec:intercept-url pattern="/secure/css/**"        access="ROLE_TIER0"/>             <sec:intercept-url pattern="/secure/images/**"     access="ROLE_TIER0"/>             <sec:intercept-url pattern="/**"                   access="ROLE_TIER0"/>       </sec:filter-invocation-definition-source>     </property>     </bean> 

I'd like to have the resources on this url...

"/nonSecure/**"

Open to all calls, i.e. no security around it.

I've tried adding ...

<sec:intercept-url pattern="/nonsecure/**" access="permitAll" /> 

But this causes Websphere to throw an error about

Unsupported configuration attributes: [permitAll]  

Can anyone tell me how to exclude this URL from security?

like image 416
jeff porter Avatar asked Aug 03 '10 08:08

jeff porter


People also ask

How do I ignore Spring Security?

What you want is to ignore certain URLs for this override the configure method that takes WebSecurity object and ignore the pattern. And remove that line from the HttpSecurity part. This will tell Spring Security to ignore this URL and don't apply any filters to them.

What dependency will you need to protect resources with Spring Security in spring boot application?

For adding a Spring Boot Security to your Spring Boot application, we need to add the Spring Boot Starter Security dependency in our build configuration file.

How do you use antMatchers?

antMatchers() is then used to apply authorization to one or more paths you specify in antMatchers() . Such as permitAll() or hasRole('USER3') . These only get applied if the first http. antMatcher() is matched.


1 Answers

In spring security 3.1.x the use of filters="none" is deprecated. Instead you use multiple <http> tags like this:

<http pattern="/nonsecure/**" security="none"/> 

http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#ns-form-and-basic

like image 64
enyo Avatar answered Oct 15 '22 13:10

enyo