1

I use Spring Security 3.0 and I would like to define a Basic Authentication filter only on a specific subset of URLs in my application.

Is it possible to add a pattern to custom-filters ?

I would like to add a pattern attribute like this :

<security:custom-filter ref="basicAuthenticationFilter" position="BASIC_AUTH_FILTER" pattern="/services/**"/>

I saw it is possible to use filters attribute on intercept-url but I would not have to list them all.

1 Answer 1

1

I used a filer-chain-map to solve this issue.

    <security:filter-chain-map path-type="ant">
        <security:filter-chain pattern="/ws/**" filters="basicAuthenticationFilter"/>
    </security:filter-chain-map>

There might be a better solution though.

Sign up to request clarification or add additional context in comments.

1 Comment

It works as expected but doing this seems to create a valid session that can be used for non-matching URL afterwards. This is a logical behavior but I would like that session to be valid only for the pattern-matching URLs. Should I inspect and invalidate the session ? based on what ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.