Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5807780
update User entity for login support
mks257 Sep 5, 2025
fe6d2ea
update UserRepository with email lookup
mks257 Sep 5, 2025
38b161e
update UserService to hash passwords and use Long ids
mks257 Sep 5, 2025
5c6b5f7
add SecurityConfig with JWT, CORS, and password encoder
mks257 Sep 5, 2025
a3472b5
add security/validation and JWT; remove jbcrypt
mks257 Sep 5, 2025
1a51864
configure application.properties with JWT and CORS settings
mks257 Sep 5, 2025
794db57
changed security password
mks257 Sep 5, 2025
bc8bd11
pull
mks257 Sep 5, 2025
c9ea1b5
dependencies added
llbalch Sep 12, 2025
1b0b0f1
Auth0 authentication & Auth2 authorization added
llbalch Sep 12, 2025
bf0ac0c
Add secure client connection
llbalch Sep 12, 2025
fcae0fc
Additional environment variables pointed toward render
llbalch Sep 13, 2025
eaa8823
user login
mks257 Sep 19, 2025
afe4edc
Merge branch 'main' of https://github.com/CoffeeCodeSyndicate/MV-API-…
llbalch Sep 19, 2025
0432430
Merged with Main
llbalch Sep 19, 2025
016d3e6
Merge pull request #40 from CoffeeCodeSyndicate/auth
LaneLR Sep 19, 2025
de1cea5
user login files
mks257 Sep 19, 2025
db52b5d
Updated to show only a user's pets
llbalch Sep 19, 2025
90dbc19
Getters and Setters for owner
llbalch Sep 19, 2025
0360a78
Seeded Data
llbalch Sep 19, 2025
fa01392
Merge branch 'main' into kavya
mks257 Sep 19, 2025
315ba47
Merge pull request #42 from CoffeeCodeSyndicate/seedData
LaneLR Sep 19, 2025
b750d33
Merge pull request #41 from CoffeeCodeSyndicate/kavya
llbalch Sep 19, 2025
56f82a1
Create README.md
mks257 Sep 19, 2025
7c013f7
Update README.md
mks257 Sep 19, 2025
2fffc44
Update README.md
llbalch Sep 19, 2025
561c155
Update README.md
llbalch Sep 19, 2025
1129c18
Update README.md
llbalch Sep 19, 2025
e312df8
updated exception handler
mks257 Sep 19, 2025
ce2dcf9
updated exception handler
mks257 Sep 19, 2025
9e6bf5a
Deleted Second SecurityChainFilter instance
llbalch Sep 19, 2025
22d3d08
Merge pull request #44 from CoffeeCodeSyndicate/bugfix/securityConfig
LaneLR Sep 19, 2025
71f0a84
Merge pull request #45 from CoffeeCodeSyndicate/kavya
llbalch Sep 19, 2025
c7182a0
Revert "Kavya"
llbalch Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target/
.settings
.springBeans
.sts4-cache
.env

### IntelliJ IDEA ###
.idea
Expand Down
115 changes: 115 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# MV-API

A Spring Boot 3.5.5 RESTful API application that manages online pet adoption
through relationships between users, applications, and admin management.
Includes registration, login, and secured endpoints, with support for role-based access.


---

## 🚀 Features
- User registration & login
- Authentication & Authorization with **Auth0 and OAuth**.
- Ownership enforcement
- Password hashing with **BCrypt**
- JWT access & refresh tokens
- Global exception handling
- H2 database for dev/test
- CORS configuration for frontend (React/Vue/Angular)
- Actuator endpoints for health checks

---

## 📦 Tech Stack
- **Java 21**
- **Maven**
- **Spring Boot 3.5.5**
- Web
- Data JPA
- Security
- Validation
- Actuator
- **JJWT 0.11.5**
- **H2 Database** (dev/test)

---

## ⚙️ Getting Started

### Prerequisites
- Java 21
- Maven 3.9+
- VS Code or IntelliJ IDEA
- Cloned repository

### Build & Run
```bash
./mvnw clean install
./mvnw spring-boot:run
App will be available at 👉 http://localhost:8080

🔑 Authentication Flow
1. Register a User
http
Copy code
POST /api/auth/register
Content-Type: application/json

{
"email": "user@example.com",
"username": "testuser",
"password": "password123"
}
2. Login
http
Copy code
POST /api/auth/login
Content-Type: application/json

{
"email": "user@example.com",
"password": "password123"
}
✔️ Returns a JWT token.

3. Call Protected Endpoint
http
Copy code
GET /api/users/me
Authorization: Bearer <your_jwt_token>
⚙️ Configuration
Edit src/main/resources/application.properties:

properties
Copy code
spring.application.name=MV-API

# JWT
security.jwt.secret=mysupersecretkeymysupersecretkey123!
security.jwt.expMinutes=60
security.jwt.refreshDays=14

# CORS
app.cors.allowed-origins=http://localhost:5173,http://localhost:3000
🐳 Docker
Build & run in Docker:

bash
Copy code
docker build -t mv-api .
docker run -p 8080:8080 mv-api
📂 Project Structure
graphql
Copy code
src/main/java/com/coffeecodesyndicate/api
├── config/ # Security, JWT, exception handling
├── controllers/ # REST controllers (Auth, User, Admin, etc.)
├── dto/ # DTOs for requests & responses
├── models/ # Entities (User, Application, Pet, etc.)
├── repositories/ # Spring Data JPA repositories
├── services/ # Business logic
└── MvApiApplication.java # Main entry point
🧪 Testing
bash
Copy code
./mvnw test
80 changes: 54 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.5</version>
<relativePath/>
</parent>

<groupId>com.coffeecodesyndicate</groupId>
<artifactId>api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MV-API</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>

<properties>
<java.version>21</java.version>
</properties>
<dependencies>

<dependencies>
<!-- Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Core -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<!-- Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- DB (H2 for dev/test) -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Security (includes BCrypt password encoder) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!-- Bean Validation (Jakarta) -->
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
<groupId>com.okta.spring</groupId>
<artifactId>okta-spring-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- JWT (JJWT) -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
Expand All @@ -85,6 +87,14 @@
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>

<!-- OAuth2 client (keep if you plan SSO later) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>

<!-- Thymeleaf (keep if you have server-side views) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
Expand All @@ -93,10 +103,29 @@
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- Optional: rate limiting
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>8.10.1</version>
</dependency>
-->
</dependencies>

<build>
Expand All @@ -107,5 +136,4 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.coffeecodesyndicate.api.config;

/**
* Custom exception to represent 409 Conflict errors,
* e.g., when a username or email is already in use.
*/
public class ConflictException extends RuntimeException {

public ConflictException(String message) {
super(message);
}

public ConflictException(String message, Throwable cause) {
super(message, cause);
}
}
Loading