https://github.com/arturbomtempo-learning/secure-rest-api-spring-boot-jwt
A project developed to deepen understanding of Spring Security and JWT in a Spring Boot application.
https://github.com/arturbomtempo-learning/secure-rest-api-spring-boot-jwt
auth0 h2-database java jwt lombok spring spring-boot spring-data-jpa spring-security spring-web
Last synced: about 2 months ago
JSON representation
A project developed to deepen understanding of Spring Security and JWT in a Spring Boot application.
- Host: GitHub
- URL: https://github.com/arturbomtempo-learning/secure-rest-api-spring-boot-jwt
- Owner: arturbomtempo-learning
- License: mit
- Created: 2025-04-23T22:07:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-26T02:35:32.000Z (about 1 year ago)
- Last Synced: 2025-10-26T00:48:00.226Z (8 months ago)
- Topics: auth0, h2-database, java, jwt, lombok, spring, spring-boot, spring-data-jpa, spring-security, spring-web
- Language: Java
- Homepage:
- Size: 2.79 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
SecureAuth API
SecureAuth API is a simple, introductory RESTful service designed to explore the fundamentals of token-based security with Spring Boot. Leveraging Spring Security and JWT, this project demonstrates basic user registration, authentication, and protected resource access, offering a hands-on learning experience for implementing secure Java backend applications.
## π Table of Contents
- [About](#about)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Application Demonstration](#application-demonstration)
- [Setup and Run the Application](#setup-and-run-the-application)
- [Technologies](#technologies)
- [Author](#author)
- [License](#license)
## π Features
All API routes for the listed features have been fully developed and are functional. As this project is purely educational, there is no front-end implementation. Below is a detailed list of the features and their status:
- [x] User registration
- [x] User login
- [x] Client-only route access
- [x] Administrator-only route access
- [x] Token validation
## π² Application Demonstration
Since this is a backend API, you can test it locally using Insomnia or other API testing services like Postman. Below are the images showcasing the typical workflow:
- Create a user

- Log in and obtain a JWT token

- Test general endpoints (token validation)

- Test client-only routes

- Test admin-only routes with a client token (results in failure due to lack of admin permission)

## π Setup and Run the Application
### βοΈ Prerequisites
Before starting, you need to have the following tools installed on your machine: [Git](https://git-scm.com) and [Java 21+](https://www.oracle.com/br/java/technologies/downloads/).
Itβs also recommended to use an IDE like [Visual Studio Code](https://code.visualstudio.com/) (with the Java Extension Pack) or [IntelliJ IDEA](https://www.jetbrains.com/idea/).
### π How to Run the Application
#### Back-End Setup
```bash
# Clone this repository
$ git clone https://github.com/ArturColen/secure-rest-api-spring-boot-jwt.git
# Navigate to the project folder
$ cd secure-rest-api-spring-boot-jwt
# Run the application
# Option 1: If using an IDE, open the project and run the main class (annotated with @SpringBootApplication)
# Option 2: If using the terminal, run the following command:
$ ./mvnw spring-boot:run
```
The server will start on port 8080 by default β you can now test the API using tools like [Insomnia](https://insomnia.rest/download) or [Postman](https://www.postman.com/downloads/).
## π» Technologies
The following tools and frameworks were used in the development of this project:
- [**Java**](https://docs.oracle.com/en/java/): A high-level, class-based, object-oriented programming language designed for reliability and platform independence.
- [**Spring Boot**](https://docs.spring.io/spring-boot/docs/current/reference/html/): A framework for building production-ready applications with minimal configuration.
- [**Spring Data JPA**](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/): A module of Spring for data access using the Java Persistence API (JPA).
- [**Spring Web**](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html): A module of Spring for building web applications, including RESTful services.
- [**Spring Security**](https://docs.spring.io/spring-security/reference/): A powerful and customizable authentication and access-control framework.
- [**Lombok**](https://projectlombok.org/): A Java library that helps reduce boilerplate code by generating common methods like getters and setters.
- [**H2 Database**](https://www.h2database.com/html/main.html): A lightweight, in-memory database often used for development and testing.
- [**JWT (JSON Web Tokens)**](https://jwt.io/introduction): A compact, URL-safe means of representing claims to be transferred between two parties.
- [**Auth0**](https://auth0.com/docs): A platform for implementing authentication and authorization in applications.
## π¨π»βπ» Author
---
| [
Artur Bomtempo](https://arturbomtempo.dev/) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------: |
Developed by Artur Bomtempo ππ». Get in touch:
[](mailto:arturbcolen@gmail.com)
[](https://www.linkedin.com/in/artur-bomtempo/)
[](https://www.instagram.com/arturbomtempo.dev/)
## π License
Copyright (c) 2025 Artur Bomtempo Colen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.