spring-projects / spring-projects/spring-security

SEC-2731: Improve migration from deprecated filterProcessesUrl properties

Open
#2,956 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Ian Brandt (Migrated from SEC-2731) said:

With the introduction of the RequestMatcher API LogoutFilter.setFilterProcessesUrl(java.lang.String) for example and its respective getter have been deprecated, but there is no JavaDoc explaining what to use instead.

Viewing the source reveals that LogoutFilter.FilterProcessUrlRequestMatcher is being used instead, but it's a private inner class, and hence can't be used by clients.

[AbstractAuthenticationProcessingFilter](http://docs.spring.io/autorepo/docs/spring-security/3.2.5.RELEASE/apidocs/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.html) has the same issue, and notably duplicates the [FilterProcessUrlRequestMatcher](https://github.com/spring-projects/spring-security/blob/3.2.5.RELEASE/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java#L463) private inner class.

Searching the [matchers](http://docs.spring.io/autorepo/docs/spring-security/3.2.5.RELEASE/apidocs/org/springframework/security/web/util/matcher/package-summary.html) package reveals the [RequestMatcherEditor](http://docs.spring.io/autorepo/docs/spring-security/3.2.5.RELEASE/apidocs/org/springframework/security/web/util/matcher/RequestMatcherEditor.html) PropertyEditor, but that's not a drop-in replacement because it uses the [ELRequestMatcher](http://docs.spring.io/autorepo/docs/spring-security/3.2.5.RELEASE/apidocs/org/springframework/security/web/util/matcher/ELRequestMatcher.html):

<property name="logoutRequestMatcher" value="/logout.do" />
Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'logoutFilter' defined in class path resource [spring-security.xml]: 
Initialization of bean failed; nested exception is org.springframework.expression.spel.SpelParseException: 
EL1070E:(pos 0): Problem parsing left operand

I got it to work with:

<property name="logoutRequestMatcher">
    <bean class="org.springframework.security.web.util.matcher.RegexRequestMatcher">
        <constructor-arg name="pattern" value="/logout\.do.*" />
        <constructor-arg name="httpMethod">
            <null />
        </constructor-arg>
    </bean>
</property>

That's a bit verbose to say the least. It also lacks consistency compared to other URLs specified for other Spring Security API:

<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
    <constructor-arg name="loginFormUrl" value="/login.do" />
    <property name="useForward" value="true" />
</bean>

It would be nice if there was a better migration path for this API, and either way it would help if it was documented.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with LogoutFilter and AbstractAuthenticationProcessingFilter, focusing on their deprecated filterProcessesUrl APIs and private FilterProcessUrlRequestMatcher classes. Compare those entry points with RequestMatcherEditor and the RegexRequestMatcher example in the issue. Done means establishing a documented, usable migration path that avoids the reported expression-language failure and addresses both filters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.