Some things have been changed in Spring Security 4.x compared to previous 3.2.x branches. They are not overwhelming but you may have to deal with them so that your application can work without any problem after upgrading to Spring 4.x release. I noted them down during my upgrade process, and post here in case you need.
-
For a long time, the login processing URL, username, and password request parameter names of
UsernamePasswordAuthenticationFilter
werej_spring_security_check
,j_username
, andj_password
consecutively. They are now replaced withlogin
,username
, andpassword
by default. -
The CSRF protection feature has been available for some time, but it was disabled by default. However, Spring Security 4.x comes with CSRF protection enabled by default. This change has consequences for your web requests, especially pages that perform form submission with the HTTP POST method. You need to add an hidden input parameter as following;
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">
-
The
<http>
element haduse-expressions="false"
in the Spring 3.2.x series. Therefore,<intercept-url>
elements were usually being configured withROLE_xxx
access attributes by default. This has changed in Spring 4.x as well. From now on, Spring Security expressions are active by default, and anyone who starts using Spring Security should provideintercept-url
access attributes with expressions returning a boolean value. -
The logout processing URL has also been changed to
logout
fromspring_security_logout
.LogoutFilter
is now only accepting POST requests. Therefore, you need to add a simple logout form which is calling logout with HTTP POST method.
<form action="logout" method="post">
<input type="submit" value="Logout">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">
</form>
However, it is not currently possible to change the configuration of LogoutFilter
so that it works with HTTP GET requests.
-
RememberMeAuthenticationFilter
was querying the_spring_security_remember_me
request parameter to initiate the remember-me mechanism. This has changed toremember-me
in Spring 4.x. -
Some classes in
acl
packages were also changed. Therefore, you may need to change youracl
bean configuration if you are using ACL in your project.