Category: Java

From stateful to stateless RESTful security using Spring and JWTs – Part 2 (session-based authentication)

After a quick introduction we are now ready to begin our journey towards stateless authentication for RESTful APIs… by setting up a stateful example. Yes I know, but we have to start somewhere, right? In this part we’ll set up our project and code a couple of simple endpoints. One of those will be secured using Spring Security’s session-based authentication.

From stateful to stateless RESTful security using Spring and JWTs – Part 1 (intro)

By now “stateful” or session-based authentication is pretty much well-accepted. Frameworks such as Spring Security or Apache Shiro make it really easy to implement a decent solution in just a few easy steps. I previously discussed how to secure a Spring-based REST API using Spring Security for authentication, CSRF protection and CORS. But in some cases, session-based security might not be good enough…

403 Forbidden on web clients against cookie-based secured REST services

You are developing your web client (AngularJS or any other) against your REST services’ server, secured using cookies-based sessions and CSRF tokens sent as cookies. You’ve done everything by the book, followed the tutorials to make your security work, especially CORS and CSRF tokens. And yet you still get a pesky 403 when trying to login!

Spring Security’s CSRF protection for REST services: the client side and the server side

Spring Security offers CSRF (cross-site request forgery) protection by default for Java web applications. In this post I will examine how you can make that CSRF protection work for a web client interacting with REST-based CSRF-protected services. Both the web client’s code and the server application’s configuration will be described.