</>CodexBash
All articles
Java and Spring

Spring Security explained

How Spring Security works and how to configure it: the filter chain, authentication versus authorisation, a SecurityFilterChain for a REST API, users and password encoding, method security, JWT resource servers, CSRF and CORS, and testing secured endpoints.

CodexBash, , 5 min read

Adding Spring Security to a Spring Boot project changes everything at once: every endpoint suddenly demands a login, a generated password appears in the log, and requests that worked a minute ago return 401 or 403. It feels like magic until you see the one idea underneath: a chain of filters that every request passes through before reaching your controllers. This article explains that chain, then configures it properly for a typical REST API, with users, roles, JWTs, CSRF, CORS and tests.

Sign in to read the rest

The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.