Fast and stateless API authentication with Spring Security
Spring Security also provides stateless APIs for securing non-browser clients, such as mobile applications or other apps. We will learn how to configure Spring Security for securing stateless APIs. Also, we will figure out the important points that need to be considered when designing security solutions and improving the performance of user authentication.
API authentication with the JSESSIONID cookie
It's not a good practice for API clients to use form-based authentication, due to the essential need for providing a JSESSIONID
cookie with the chain of requests. Spring Security also provides an option to use HTTP basic authentication, which is an older approach but works fine. In the HTTP basic authentication approach, user/password details need to be sent with a request header. Let's take a look at the following example of an HTTP basic authentication configuration:
@Override
protected void configure(HttpSecurity http) throws Exception...