An educational project with Spring Framework examples. Used for lectures at courses.
- Spring Framework Documentation
- Spring Core Technologies
- Spring Guides
- Spring Quickstart Guide
- Properties with Spring and Spring Boot
- An Intro to the Spring DispatcherServlet
- Design Pattern - Front Controller Pattern
- Introduction to Using Thymeleaf in Spring
- Servlet Filter and Handler Interceptor
- Error Handling for REST with Spring
- Spring 5, Embedded Tomcat 8, and Gradle: a Quick Tutorial
- Spring Boot Reference Documentation
- The module example-17-authorization has an issue #101 that was caused because of update to Spring Security 6
Please note that IntelliJ IDEA HTTP Client was used to perform requests in code snippets
Please follow the steps to perform a demo of how to get a JWT token for an existing user:
- Perform login action
POST http://localhost:8080/#?username=user&password=user
Accept: application/json
- Extract the generated Bearer token from a response header
Authorization: Bearer <token>
HTTP/1.1 200
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyIiwiZXhwIjoxNjc4ODM2OTY1fQ.Afagk8no-r2kUiDOdtjWMT06gYPHkrhCoOSoK5_X6k8BC8Lr6k5rB-9gyoE72-lkd0rx1sEPET-3Uf7KP-7BrQ
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 0
Date: Tue, 14 Mar 2023 23:35:05 GMT
Keep-Alive: timeout=60
Connection: keep-alive
<Response body is empty>
- Use the generated Bearer token to perform the call to an endpoint by providing the
Authorization: Bearer <token>
header
GET http://localhost:8080/users/me
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyIiwiZXhwIjoxNjc4ODM1NjE5fQ.cRZ1ob4XZfG5RnU0jl2kdPihc9Ln-BlEOe7hbuwZJWp-UuQSGukI_57pWrBcdaCWPN-8luCF08YWU74tUErOFg