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
UsernamePasswordAuthenticationFilterwerej_spring_security_check,j_username, andj_passwordconsecutively. They are now replaced withlogin,username, andpasswordby 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_xxxaccess 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-urlaccess attributes with expressions returning a boolean value. -
The logout processing URL has also been changed to
logoutfromspring_security_logout.LogoutFilteris 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.
-
RememberMeAuthenticationFilterwas querying the_spring_security_remember_merequest parameter to initiate the remember-me mechanism. This has changed toremember-mein Spring 4.x. -
Some classes in
aclpackages were also changed. Therefore, you may need to change youraclbean configuration if you are using ACL in your project.