Spring Security Simple Login and Logout Example

By Arvind Rai, November 25, 2013

For any web application or enterprise software application, security is most important feature. For any application we need authentication and authorization for any user. Authentication is just to know who is accessing your application. Authorization is that if that user can perform any action in your application. Spring Security performs these two tasks in a very secure manner. So if we are developing our application, we can leave authentication and authorization responsibilities to spring security and do our business logic.
There are lots of things to learn in spring security. We can start with a simple spring security login and logout example. So find all the file description to run the example.

How to Logout in Spring Security

Logout in spring security is easy. Spring security provides a URL as j_spring_security_logout. When we request this URL, it will automatically logout. After logout, we need to redirect at any desired URL. Find the two configurations below in success.jsp and security-config.xml.