Skip to content

Project update time, expect friendly bugs! 🐾🚧🐞 A simple Java application using Spring Boot, JPA, and RESTful APIs. Requires additional repositories for OAuth2, JWT-secured endpoints, and API Gateway.

Notifications You must be signed in to change notification settings

CarinaPorumb/pet-clinic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pet Clinic CircleCI

This is a simple Java application that aims to become a pet clinic management system. The app uses JPA to handle database operations and RESTful controllers for API endpoints. Security is enforced with JWT tokens via an OAuth2 Authorization Server. Additionally, it uses Spring Cloud Gateway to manage and route requests securely.

Note: This project requires two additional repositories (Spring Cloud Gateway and OAuth2 Authorization Server Repository) to be set up and running.

Optional: For additional functionality, you may set up the Pet Clinic Client project.


Features

  • RESTful web application using Spring MVC
  • JPA integration for relational database access
  • Secured endpoints using OAuth2 and JWT tokens
  • API Gateway for handling and routing requests

Technologies Used

  • Java 21
  • Spring Boot 3.3.0
  • Spring MVC for RESTful controllers
  • Spring Security
  • Spring Data JPA
  • MySQL Database
  • OAuth2 Authorization Server with JWT

Getting Started

Prerequisites

Make sure you have the following installed on your system:

  • Java 21
  • Maven
  • Postman (or preferred HTTP client)

Installation

  • 1. Clone and Set Up the OAuth2 Authorization Server Project

This project relies on a separate OAuth2 Authorization Server project for authentication and authorization.

Clone and set up the OAuth2 project first:

git clone https://github.com/CarinaPorumb/spring-oauth2

Build the project using Maven:

mvn clean install

You can run the application using your IDE or from the command line:

 mvn spring-boot:run

Once the application is running, it will be available at http://localhost:9000.


  • 2. Clone and Set Up the Spring Cloud Gateway Project

After setting up the OAuth2 Authorization Server, clone and set up the Spring Cloud Gateway project:

git clone https://github.com/CarinaPorumb/spring-cloud-gateway

Build the project using Maven:

mvn clean install

You can run the application using your IDE or from the command line:

 mvn spring-boot:run

Once the application is running, it will be available at http://localhost:8080.


  • 3. Clone and Set Up the Pet Clinic Project

After setting up the OAuth2 Authorization Server and Spring Cloud Gateway, clone and set up the Pet Clinic project:

git clone https://github.com/CarinaPorumb/pet-clinic

Build the project using Maven:

mvn clean install

You can run the application using your IDE or from the command line:

 mvn spring-boot:run

Once the application is running, it will be available at http://localhost:8081.


Optional: Pet Clinic Client

For additional functionality, you may set up the Pet Clinic Client project. This client can interact with the Pet Clinic service for various operations.

Clone and set up the Pet Clinic Client project:

git clone https://github.com/CarinaPorumb/pet-clinic-client

Build the project using Maven:
mvn clean install

You can run the application using your IDE or from the command line:
mvn spring-boot:run

Once the application is running, it will be available at http://localhost:8082.

Startup Order

  1. Start the OAuth2 Authorization Server: http://localhost:9000
  2. Start the Pet Clinic: http://localhost:8081
  3. Start the Spring Cloud Gateway: http://localhost:8080
  4. Optional: Start the Pet Clinic Client: http://localhost:8082

Testing with Postman

To test the Pet Clinic API endpoints secured by OAuth2, I used Postman to request an access token and make authenticated requests. Here are the steps:

  1. Configure Postman for OAuth2 Authentication
  • Open Postman and create a new request.
  • Set the Request URL to your desired endpoint, e.g., http://localhost:8081/api/v2/pet.
  • Go to the Authorization tab and select OAuth 2.0 as the type.

  1. Configure a New Token
  • Token Name: Choose a name for your token, e.g., newToken.
  • Grant Type: Select Client Credentials.
  • Access Token URL: http://localhost:9000/oauth2/token
  • Client ID: messaging-client
  • Client Secret: secret
  • Scope: message.read message.write
  • Client Authentication: Select Send as Basic Auth header

  1. Request Token
  • Click on Get New Access Token.
  • Postman will request the token from the OAuth2 server.
  • If successful, the token will be displayed. Click on Use Token to set it for your request.

  1. Send the Request
  • Ensure the token is added to the request headers.
  • Send the request to the API endpoint.

About

Project update time, expect friendly bugs! 🐾🚧🐞 A simple Java application using Spring Boot, JPA, and RESTful APIs. Requires additional repositories for OAuth2, JWT-secured endpoints, and API Gateway.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages