A hands-on course that walks through Spring Security from first principles up to JWT-secured REST APIs. Each section builds directly on the previous one, ending with a working Spring Boot application that authenticates users, authorizes requests, and issues JWTs.
A Spring Boot app (Java 25, Spring Boot 4) that:
- Authenticates users via form login, HTTP Basic, and JWT
- Loads users from a database with a custom
UserDetailsService - Stores hashed passwords with BCrypt
- Models roles and permissions with JPA and
GrantedAuthority - Authorizes requests using
@PreAuthorizeand request matchers - Reacts to authentication events (success, failure, lockout)
- Issues and validates JWTs as a Spring resource server
- Java 25
- Maven (the Maven wrapper is included — use
./mvnw) - Basic Spring Boot familiarity (controllers, beans, JPA)
./mvnw spring-boot:runEach section has a matching branch. Check out the *-start branch to follow along, or the section branch to see the finished state.
| Section branch | Starter branch |
|---|---|
form-login |
starter |
basic-authentication |
basic-authentication-starter |
authentication |
authentication-starter |
user-details-service |
user-details-service-start |
security-context-holder |
security-context-holder-start |
roles-and-permission |
roles-and-permissions-start |
security-events |
security-events-starter |
jwt |
jtw-starter |
- What is Spring Security
- Form login intro, implementation, and testing
JSESSIONIDand storing it in Redis / JDBC- Form login configuration
- Inspecting the filter chain
- Configuring HTTP Basic
- Basic Auth in the browser vs server-to-server
- Configuration and CSRF
AuthenticationProviderandUserDetailsService- Noop passwords, hashing, and BCrypt
- Custom
DaoAuthenticationProvider - Using the
AuthenticationManager
- Custom
UserDetailsService - The
ApplicationUserentity and its annotations - Inspecting tables, persisting users, and fixing
loadByUsername
- Reading from
SecurityContextHolder - Injecting
Authenticationas a controller parameter
- Role and permission entities and ERD
- Saving roles and permissions through repositories
- Mapping authorities with
SimpleGrantedAuthority
@PreAuthorizeandhasAuthority- Request matchers and other authorization methods
- Capturing authentication events
- Async event handling
- Exercise
- Intro to JWT and required dependencies
- Enabling the resource server
- Encoding/decoding with a secret key
JwtTokenServiceandJwtDecoder- Inspecting tokens, the auth controller, and JWT in action
- Embedding roles and permissions in the token
JwtAuthenticationConverter
- Check out
starterto begin. - Watch a lesson, then implement it on the matching
*-startbranch. - Compare your work against the section branch when you're done.
- Move to the next section.
